Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending of badge causes Invalid JSON payload #211

Open
multi opened this issue Jul 10, 2024 · 8 comments
Open

Sending of badge causes Invalid JSON payload #211

multi opened this issue Jul 10, 2024 · 8 comments

Comments

@multi
Copy link

multi commented Jul 10, 2024

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?

@alex-friedl
Copy link
Collaborator

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)

@multi
Copy link
Author

multi commented Jul 12, 2024

@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)

@SingleMalted
Copy link

I'm seeing the same issue.

@alex-friedl
Copy link
Collaborator

@multi @SingleMalted Does it work for you to wrap your payload in a fcm_notification ?

@SingleMalted
Copy link

@alex-friedl I'm using the v1 API and it's sent via fcm.

@alex-friedl
Copy link
Collaborator

alex-friedl commented Aug 10, 2024

@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

@SingleMalted
Copy link

@alex-friedl Yes, that's what I'm currently doing.
Thanks

@vitalyster
Copy link
Contributor

vitalyster commented Sep 2, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants