FCM AdminSDK中IOS的“ TimeToLive”

问题描述

如果我将“ ttl”值设置为10秒钟,我将不会收到任何通知。在android上工作正常,但对于ios,即使一分钟后我也可以收到通知

//代码

 DateTime epochStart = new DateTime(1970,01,DateTimeKind.Utc);
 TimeSpan currentTs = DateTime.UtcNow - epochStart;
 var ttlExpiryTimeIOS = Convert.ToUInt64(currentTs.TotalSeconds)+Convert.ToInt32(10);//add 10sec to 
time
Dictionary<string,string> ttlDictValue = new Dictionary<string,string>
{
 {
 "apns-expiration",ttlExpiryTimeIOS.ToString()}
 };
 Message message = new Message()
            {
                Apns = new ApnsConfig { Aps = aps,Headers = ttlDictValue },Token = devicetoken,Notification = new Notification()
                {
                    Body = "Hello World",Title = "Hello World",ImageUrl = "https://i.picsum.photos/id/142/200/200.jpg",},Android = new AndroidConfig() { Notification = android,TimetoLive = new TimeSpan(0,20) },Data = customData,};
            var result = await messaging.SendAsync(message).ConfigureAwait(true);
      }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)