Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let manager = AFHTTPRequestOperationManager()
- manager.requestSerializer.setValue("key=yourServerKey", forHTTPHeaderField: "Authorization")
- manager.requestSerializer.setValue("application/json", forHTTPHeaderField: "Content-Type")
- let sendPushForChatUrl = "https://fcm.googleapis.com/fcm/send"
- let to = otherUserPushToken as! String
- let notification = notificationData as! [String: AnyObject]
- let param = ["to":to, "content_available":true, "priority":"high", "notification":notification] as [String : Any]
- manager.post(sendPushForChatUrl,
- parameters: prepareObjects(param),
- success: { (operation: AFHTTPRequestOperation?,responseObject: Any?) in
- print("Suceess")
- print(responseObject ?? "")
- } ,
- failure: { (operation: AFHTTPRequestOperation?,error: Error?) in
- print("Error: " + error!.localizedDescription)
- print("Fail")
- })
- {
- "to":"userPushToken",
- "priority":"high",
- "content_available": true,
- "notification":{
- "notification-type":"chat",
- "target":"Current User",
- "title":"Current User has sent you a message",
- "text": "hello1",
- "badge": 5 //Badge you want to show on app icon
- }
- }
Add Comment
Please, Sign In to add comment