Guest User

Untitled

a guest
Dec 18th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. let manager = AFHTTPRequestOperationManager()
  2. manager.requestSerializer.setValue("key=yourServerKey", forHTTPHeaderField: "Authorization")
  3. manager.requestSerializer.setValue("application/json", forHTTPHeaderField: "Content-Type")
  4. let sendPushForChatUrl = "https://fcm.googleapis.com/fcm/send"
  5.  
  6. let to = otherUserPushToken as! String
  7. let notification = notificationData as! [String: AnyObject]
  8.  
  9. let param = ["to":to, "content_available":true, "priority":"high", "notification":notification] as [String : Any]
  10.  
  11. manager.post(sendPushForChatUrl,
  12. parameters: prepareObjects(param),
  13. success: { (operation: AFHTTPRequestOperation?,responseObject: Any?) in
  14.  
  15. print("Suceess")
  16. print(responseObject ?? "")
  17. } ,
  18. failure: { (operation: AFHTTPRequestOperation?,error: Error?) in
  19. print("Error: " + error!.localizedDescription)
  20. print("Fail")
  21. })
  22.  
  23. {
  24. "to":"userPushToken",
  25. "priority":"high",
  26. "content_available": true,
  27. "notification":{
  28. "notification-type":"chat",
  29. "target":"Current User",
  30. "title":"Current User has sent you a message",
  31. "text": "hello1",
  32. "badge": 5 //Badge you want to show on app icon
  33. }
  34. }
Add Comment
Please, Sign In to add comment