首页 > 解决方案 > FCM 是否支持 iOS 13 的新 apns-push-type

问题描述

我们目前有一个解决方案,可以将推送通知从 FCM 发送到 APNS,然后再发送到 iOS。由于 iOS13 的引入,APNS 现在在任何传入的有效负载中都需要 apns-push-type 来指定它是警报通知、后台通知还是任何其他类型。我想知道如何在发送到 FCM 的消息中添加此信息。

目前我们使用 pyFCM 向 FCM 发送消息。我们将此页面作为参考:https ://firebase.google.com/docs/cloud-messaging/http-server-ref

from pyfcm import FCMNotification
push_service = FCMNotification(api_key="XXXX")
registration_id = '<Token>'
data_message = {
    "Score": "3*1",
    "DeviceId": "XXXXXX",
}

# Background notification
result = push_service.notify_single_device(registration_id=registration_id,
                                       content_available=True,
                                       data_message=data_message)

# Alert notification
result = push_service.notify_single_device(registration_id=registration_id,
                                       message_title='Sample title',
                                       message_body='Sample body',
                                       data_message=data_message,
                                       )

这适用于现有的 iOS 应用程序。但是对于 iOS 13,我找不到任何地方来指定 apns-push-type 或 FCM 将转换为将发送到 APNS 的 apns-push-type 的任何等效字段。

我知道 iOS 13 相对较新,所以每个人仍在努力适应现有的解决方案。希望有人能给我一些见解,如何将 apns-push-type 放入我现有的解决方案中。谢谢。

标签: firebase-cloud-messagingios13

解决方案


只需在要发送到 FCM 的请求标头中添加 'apns-push-type' = 'XXX'


推荐阅读