Skip to content
Advertisement

How to send FCM notification to all android devices using Node.js

I want to send the notification to my Android app developed using Ionic t from Node.Js code. I have tried following code and getting Exactly one of topic, token or condition is required.

How can I send notification all my users without any condition?

JavaScript

Advertisement

Answer

If you want to send a notification to all users, then the best thing is to register the users to a certain topic, example food then everyone registered to that topic will receive a notification.

In your code above, you are getting that error because you did not provide to whom you want to send the notification.

If token:

JavaScript

If topic:

JavaScript

more info here:

https://firebase.google.com/docs/cloud-messaging/admin/send-messages

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement