This question already has answers here:
Closed 3 years ago.
I have this app, and I've enabled push notifications on it. I'm able to send notifications through the Firebase console, but what I really wanna do, is to be able to send a notification to specific users, when an action is taken on the app.. I've tried to follow the Firebase docs, but the documentations about this, seems really poor..
It tells you to use this method:
FIRMessaging.messaging().sendMessage(message: ([NSObject : AnyObject]), to: (String), withMessageID: (String), timeToLive: (Int64))
But I can't really figure out what to put in as parameters, and as mentioned, the documentation doesn't really help much..
Have anyone tried using this method, and if yes, how is it done? Appreciating any help, thanks!
As far as I know it is not possible to trigger sending push notifications from a device with firebase. What you need is a separate service (running on a different server) which has the necessary rights to access the device tokens which are managed by firebase and send push notifications to certain devices. All this will have to run over your Nosql firebase database.
You could store your Push notification requests in your database and let your push notification service listen to that path. if there is a request coming in from a device you trigger sending the notification and delete the request from the database.
you could use a nodejs app with this package: https://www.npmjs.com/package/fcm-node