IOS 未通过 fcm 接收 Firebase 通知,而仅在 ANDROID 上接收

时间:2021-07-06 07:47:15

标签: ios firebase flutter push-notification

任何人都可以帮助我为什么我的 iOS 设备在我通过 fcm 测试推送通知时无法接收任何触发器?与android相比,一切正常。这是一张我已经启用我的 Xcode 配置的照片。这是我跟踪集成和设置的链接 https://firebase.flutter.dev/docs/messaging/overview/

enter image description here

1 个答案:

答案 0 :(得分:0)

这很棘手...

假设您按照 Apple integration docs...

  • 首先,您不能在 iOS 模拟器上运行:
<块引用>

通过 APNs 的 FCM 不适用于 iOS 模拟器。接收消息 & 通知需要真实设备。

来源:https://firebase.flutter.dev/docs/messaging/apple-integration

  • 然后,根据我的经验,iOS 和 Android 对 FCM 加载使用不同的格式。这样的事情应该可以工作
          // CONSTRUCT NOTIFICATION PAYLOAD 
          message = {
            "notification": {
              "body": body,
            },
            // apple push notification service
            "apns": {
              "payload":
              {
                "aps": {
                  "alert": {
                    "body": body,
                  },
                  "sound": "default",
                },
              }
            },
            token: fcmToken,
          };

见:https://firebase.flutter.dev/docs/messaging/usage/

另见:https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#ApnsConfig