Reputation: 440
I'm starting to use firebase cloud messaging for my current app in order to send a notification. The only problem is, the message is triggered from an element inside the app. If an individual would want to trigger a notification programmatically, how would they do it (still using fcm) in swift?
I would just use a local notification, but, I've already gone through the hell of setting up fcm already. (Plus, all my user data is in Firebase)
EDIT I've found out that Firebase Cloud Messaging has a function called FIRMessaging.messaging.sendMessage(message: message, to: , withMessageID, timeToLive)
I understand how this would work, but... I don't understand what it means by 'to' and 'withMessageID'. Could someone please explain this?
Upvotes: 4
Views: 3766
Reputation: 1319
The FIRMessaging.messaging.sendMessage(message: message, to: , withMessageID, timeToLive)
is for sending upstream messages from iOS to server. First of all, is this the use case you are looking for? Or you want to send message from server to device(downstream)?
For sending upstream messages, read this might help :
https://firebase.google.com/docs/cloud-messaging/ios/upstream
For implementing FCM server and sending downstream messages, read this(its pretty straight forward):
https://firebase.google.com/docs/cloud-messaging/server
And here you are some github repos about FCM server:
https://github.com/search?utf8=✓&q=fcm+server
Upvotes: 4