美文网首页
iOS Silent Remote Notification

iOS Silent Remote Notification

作者: 赵哥窟 | 来源:发表于2022-02-25 10:37 被阅读0次

Silent Remote Notifications 推送唤醒,静默推送

Silent Remote Notification 的用处

推送唤醒:
静默推送只能在应用在前台和应用在后台挂起时执行,也就是说,如果应用未启动或进程被杀掉,静默推送是唤醒不了设备的。后台可以唤醒App 更新数据,更新UI,我们最多有30s的时间来处理数据。

普通推送:

收到推送后(有文字有声音),点开通知,进入APP后,才执行

- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
  
}
静默推送:收到推送(没有文字没有声音),不用点开通知,不用打开APP,就能执行
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
  
}

用户完全感觉不到

消息格式
{
    "aps":{
        "参数":"XXX",
        "content-available":1,
        "alert":"",
        "badge":0
    }
}

1、只要推送payload中aps字典里包含了"content-available": 1的键值对,都具有静默推送的特性。
2、alert字段必须为空,否则收到的就不是静默推送

截屏2022-02-25 上午10.16.05.png

相关文章

网友评论

      本文标题:iOS Silent Remote Notification

      本文链接:https://www.haomeiwen.com/subject/exdxrrtx.html