我正在尝试设置一个 Firebase 云函数,该函数将触发带有有效负载的云消息传递。然而,该函数接收到的负载包含 Apple APNS token 而不是 FCM token ,我在 Firebase Admin SDK 中没有看到任何允许 APNS token 而不是 FCM 的方法。
这是否意味着我必须编写自己的 APNS Provider 而不能使用 FCM?!
最佳答案
Does that mean that I have to write my own APNS Provider and not use FCM?!
你可以这样做。我不明白这是多么令人震惊。为了使用 FCM,您需要使用 FCM token 。这就是服务的工作方式。
尽管如此,您还可以使用 InstanceID 服务器 API 到 create registration tokens with the APNs tokens :
Create registration tokens for APNs tokens
Using the Instance ID service's batchImport method, you can bulk import existing iOS APNs tokens to Google Cloud Messaging or Firebase Cloud Messaging, mapping them to valid registration tokens. Call the Instance ID service at this endpoint, providing a list of APNs tokens in the JSON body:
https://iid.googleapis.com/iid/v1:batchImport
The response body contains an array of Instance ID registration tokens ready to be used for sending FCM or GCM messages to the corresponding APNs device token.
关于使用 APNS token 而非 FCM token 的 Firebase 云函数消息传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50344633/