4

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?

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thankyou so much for this answer, but can you elaborate or show an example for 'FIRMessaging.messaging.sendMessage(message: message, to: , withMessageID, timeToLive)'

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.