APNS 内容可用推送在 iOS 15 中不起作用

Pra*_*abu 5 payload apple-push-notifications silentpush silent-notification ios15

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

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

{"aps":{"content-available":1},"update":"2|1"}
Run Code Online (Sandbox Code Playgroud)

但通知消息推送正常

{"aps":{"alert":"welcome"}}
Run Code Online (Sandbox Code Playgroud)

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

小智 1

就在这里。根据苹果的文档

\n
\n

notification\xe2\x80\x99s POST 请求应包含值为 background 的 apns-push-type 标头字段和值为 5 的 apns-priority 字段。 APNs 服务器在以下情况下需要 apns-push-type 字段:向 Apple Watch 发送推送通知,并推荐所有平台使用。

\n
\n

标题看起来像这样:

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