node-pushnotifications
node-pushnotifications copied to clipboard
Sending of `badge` causes Invalid JSON payload
When badge is used, that's the response from FCM
Invalid JSON payload received. Unknown name \"badge\" at 'message.android.notification': Cannot find field.
I've tried removing that line and it works, also there's a badge dot icon on the phone, so notification_count is sufficient for Android?
Looks like you're still using the deprecated GCM method for sending Android notifications. Have you tried setting isLegacyGCM: false and using FCM ?
Alternatively, if you want to continue using the deprecated GCM API, then you could wrap your fixed payload via data.fcm_notification and it should work as well (the line you linked checks that key first before defaulting to the object construction with the incorrect badge usage)
@alex-friedl Hey 👋
As far as I can see, the new FCM implementation uses node-gcm to build the message here and here.
isLegacyGCM is false by default
The only option I've changed is isAlwaysUseFCM: true (false by default)
I'm seeing the same issue.
@multi @SingleMalted Does it work for you to wrap your payload in a fcm_notification ?
@alex-friedl I'm using the v1 API and it's sent via fcm.
@SingleMalted The line you referenced allows you to pass a custom payload as { fcm_notification: { ... } }. Couldn't you simply pass it there without badge in it?
I am not sure about simply removing that line and possibly breaking things for other users
@alex-friedl Yes, that's what I'm currently doing. Thanks
Still not clear how to set badge number with recent update both for apn and fcm? badge is documented as a shortcut for gcm + apn