Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. Messaging.messaging().apnsToken = deviceToken
  2. //FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: .none)
  3. // Messaging.messaging().setAPNSToken(deviceToken, type: .sandbox)
  4. }
  5.  
  6. @objc func tokenRefereshNotification()
  7. {
  8. let refereshtoken = InstanceID.instanceID().token() ?? ""
  9.  
  10. print("token23123::::(refereshtoken)")
  11. UserDefaults.standard.set(refereshtoken, forKey: "deviceToken")
  12. connectToFCM()
  13. }
  14.  
  15. func connectToFCM()
  16. {
  17. guard InstanceID.instanceID().token() != nil else
  18. {
  19. return
  20. }
  21.  
  22. Messaging.messaging().disconnect()
  23. Messaging.messaging().connect { (error) in
  24.  
  25. if (error != nil)
  26. {
  27. print("error unable to connect(String(describing: error))")
  28. }
  29. else
  30. {
  31. print("connect to fcm")
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement