1

Ultimately I would like to send custom push notifications when a message is received like What's App. I've been reading the documentation about Firebase Cloud Messaging here. Essentially an HTTP POST request is sent to generate the notification.

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA

{
  "to" : /topics/foo-bar",
  "priority" : "high",
  "notification" : {
    "body" : "This is a Firebase Cloud Messaging Topic Message!",
    "title" : "FCM Message",
  }
}

Is it possible to do this client side in Swift?

Peter Tao
  • 1,668
  • 6
  • 18
  • 29
  • 1
    Hi Peter. In general, it is ***strongly advised*** not to send downstream messaging from the client app side in any platform, since when making the requests, you'll have to include your *Server Key* in your client app code. This exposes it to unauthorized users for exploitation. – AL. Mar 23 '17 at 15:21

1 Answers1

0

You can use URLSession or URLConnection or third part libraries such as Alamofire. By the way this is highly discouraged because in this way you'll have to hard code your server key in the client. You should consider to use the Cloud Functions for Firebase.

Community
  • 1
  • 1
Gnammo
  • 255
  • 2
  • 8