On Google's Firebase website, in order to send downstream messages, I have to do an HTTP Post request. This is what it says to do:
Sending downstream messages from the server:
To address or "target" a downstream message, the app server sets to with the receiving client app's registration token. You can send notification messages with predefined fields, or custom data messages; see Notifications and data in the message payload for details on payload support. Examples in this page show how to send data messages in HTTP and XMPP protocols.
HTTP POST Request
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{ "data": {
"score": "5x1",
"time": "15:10"
},
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..."
}
How do I do this in Swift 2?
Solution Update
Swift 4 + further insight on how to tweak the FCM in Swift
Locate your server key at Project Settings > Cloud Messaging > Server Key
People down-voted this question, and it's a shame. I've been researching this topic for over 4 months now, and no other stackoverflow question/answer has helped me.
Anyway, I've found the solution, specific to Google's Firebase Cloud downstream messaging. This sends a message to the Google server that pushes notifications to all users via a HTTP POST request.
Before doing any of the code below, be sure to follow the steps to setting up an iOS client for Firebase, installing all the correct pods and getting your certificates, provisioning profile, etc. here.
View Controller:
App Delegate:
If anybody has any questions, please feel free to ask! I also know how to send to topics.
Thanks!