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.)
While Google takes its time to fix this, we could successfully send silent notifications 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.