首页 > 解决方案 > APNS 内容可用推送在 iOS 15 中不起作用

问题描述

当应用程序使用 Xcode 13.0、iOS 15 SDK 构建时,iOS 15 设备中未收到 APNS 内容可用推送。

推送内容可用的有效负载数据:1 不工作

{"aps":{"content-available":1},"update":"2|1"}

但正常的通知消息推送工作

{"aps":{"alert":"welcome"}}

iOS 15 静默推送消息的标头字段中是否有任何有效负载或配置?

标签: apple-push-notificationspayloadios15silent-notificationsilentpush

解决方案


就在这里。根据Apple 的文档

通知的 POST 请求应包含值为 background 的 apns-push-type 头字段和值为 5 的 apns-priority 字段。APNs 服务器在向 Apple Watch 发送推送通知时需要 apns-push-type 字段,并为所有平台推荐它。

标题如下所示:

request_headers = {
    'apns-expiration': '0',
    'apns-priority': '5', # must be 5 for silent pushes, otherwise it will not be sent
    'apns-topic':'your_app_bundle_id',
    'authorization': 'bearer your_jwt_token'
    'apns-push-type': 'background' # this field is not required
}

推荐阅读