代码之家  ›  专栏  ›  技术社区  ›  Tristan

FCM引发IOS通知的无效参数

  •  0
  • Tristan  · 技术社区  · 4 年前

    我的项目以前有工作通知,我无法跟踪我发送的负载的任何更改。我引用了文档,看不到我的负载有任何问题。我得到的确切错误是

    请求包含无效参数

    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'
            }
        }
    };
    

    我当前的有效负载:

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

    关于这个问题已经有多个问题了。这是我发现的最好的一个: firebase cloud messaging Request contains an invalid argument

    我无法找出任何会导致通知在上周左右停止工作的差异。我知道他们当时正在工作,我已经查看了Github的历史记录,以验证有效负载没有发生变化(除了我对 可用内容 我今天做了一个测试。)

    0 回复  |  直到 4 年前
        1
  •  1
  •   Gabriel Diéguez    4 年前

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

    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

    希望它能帮助我们等待一个明确的解决方案。

    推荐文章