apple-push-notifications - 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 的文档:
通知的 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
}
推荐阅读
- javascript - AMP 设置和获取 cookie 值
- android - 错误:ADB 以退出代码 1 退出正在执行流式安装
- apache-kafka - 带有 kerberos 的 kafka-console-consumer 抛出没有枚举常量异常
- javascript - 如何使用 jquery 设置和重新设置 dropify 默认图像?
- python - SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 51-52: malformed \N character escape
- javascript - 获取价值数据并根据每个环节变化?
- javascript - javascript 中的实用程序映射器函数
- amazon-web-services - 使用 SES 发送带有多个附件的电子邮件
- reactjs - 成功“提交”后 ReduxForm 重置表单
- python - Spark Python - 从结构中选择并从特定深度返回