FCM Throwing invalid-argument for IOS notifications
Asked Answered
R

1

9

My project had working notifications previously and I can't trace any changes to the payload I've been sending. I've referenced the docs and can't see any issues with my payload. The exact error I am getting is

Request contains an invalid argument

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

My current payload:

After taking a fresh look at the Apple docs for notifications I noticed that I should be using content-available. I had previously been using contentAvailable: true (and it was working). Neither one is working anymore.

There are multiple questions regarding this problem already. This one being the best I've found: firebase cloud messaging Request contains an invalid argument

I verified that the token is correct by sending the device a test notification from the firebase console. I don't think I should be hitting the size limit of 4kb, the message I am sending for testing is something along the lines of 'test' or 'hello' (also the issue is IOS specifi). I've also verified that the headers I am sending are current with the Apple docs.

I can't figure out any differences that would cause notifications to stop working within the last week or so. I know they were working then and I've gone through my Github history to verify the payload hasn't changed (besides my change to content-available I made today while testing.)

Revision answered 12/4, 2021 at 2:24 Comment(4)
We are seeing the same behavior on our project, and we tested directly against the HTTP v1 send endpoint and got an "Invalid registration token" error, which is of course wrong. We just opened a GitHub issue, feel free to react or comment: github.com/firebase/firebase-admin-node/issues/1224Periodontal
We are also seeing the same problem at the moment. Waiting on a comment on the github issue opened by GabrielParchment
They just commented that the FCM backend team identified the issue, expecting to have it fixed "within a week".Periodontal
Looks like the issue has been resolved on Google's side of things. I verified they are working for my app again.Revision
G
2

While Google takes its time to fix this, we could successfully send silent notifications using the legacy app server protocols:

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

The endpoint we are using is https://fcm.googleapis.com/fcm/send.

Here you can find the message structure (note that is quite different from the current API):

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

And here how to authorize the requests:

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

Hope it helps while we wait for a definitive fix.

Gametangium answered 13/4, 2021 at 17:56 Comment(2)
Thanks for this. Luckily my app is still in a beta and I can just let my testers on IOS know notifications are broken for now. Hopefully they get this fixed fairly quickly and I won't need to use the legacy endpoint.Revision
Accepted, this was said on the Github "Latest update: FCM backend performed a fast rollback today. The backend should be at the good version without this issue now."Revision

© 2022 - 2024 — McMap. All rights reserved.