FCM 为 IOS 通知抛出无效参数

Tri*_*tan 9 apple-push-notifications ios firebase react-native firebase-cloud-messaging

我的项目以前有工作通知,我无法追踪我发送的有效负载的任何更改。我已经参考了文档,但看不到我的有效负载有任何问题。我得到的确切错误是

请求包含无效参数

let payload = {
    token : oUser.devicetoken,
    data : {
        referenceid : chatid,
        referencetype : 'chat',
        referencename : oSender.displayname,
        receiverid : userid,
        type : 'message',
        notificationid : res,
        title : title,
        body : `${oSender.displayname} : ${body}`
    },
    android : {
        priority : 'high'
    },
    apns : {
        payload : {
            aps : {
                'content-available' : 1
            }
        },
        headers : {
            'apns-push-type' : 'background',
            'apns-priority' : '5',
            'apns-topic' : 'llc.attebyte.partyme'
        }
    }
};
Run Code Online (Sandbox Code Playgroud)

我当前的有效载荷:

在重新查看 Apple 文档的通知后,我注意到我应该使用content-available. 我以前一直在使用contentAvailable: true(并且它正在工作)。两个人都不再工作了。

关于这个问题已经有多个问题了。这是我发现的最好的一个:firebase 云消息传递请求包含无效参数

我通过从 Firebase 控制台向设备发送测试通知来验证令牌是否正确。我认为我不应该达到 4kb 的大小限制,我发送用于测试的消息是类似于“测试”或“你好”的内容(也是 IOS 特定的问题)。我还验证了我发送的标头与 Apple 文档是最新的。

我想不出任何会导致通知在上周左右停止工作的差异。我知道他们当时正在工作,并且我已经查看了我的 Github 历史记录以验证有效负载没有改变(除了我content-available今天在测试时所做的更改。)

Gab*_*uez 2

虽然 Google 花时间解决这个问题,但我们可以使用旧的应用程序服务器协议成功发送静默通知:

https://firebase.google.com/docs/cloud-messaging/send-message#send-messages-using-the-legacy-app-server-protocols

我们使用的端点是https://fcm.googleapis.com/fcm/send.

在这里你可以找到消息结构(注意这与当前的 API 有很大不同):

https://firebase.google.com/docs/cloud-messaging/http-server-ref

这里是如何授权请求:

https://firebase.google.com/docs/cloud-messaging/auth-server#authorize-http-requests

希望在我们等待最终修复时它能有所帮助。