Correct way to retrieve token for FCM - iOS 10 Swift 3

前端 未结 15 2054
日久生厌
日久生厌 2021-01-31 02:42

i had implement Firebase with FirebaseAuth/FCM etc and did sent notification successfully through Firebase Console.

However i would need to push the notification from m

15条回答
  •  佛祖请我去吃肉
    2021-01-31 03:03

    confirm to MessagingDelegate protocol.

    then you can add below delegate method and get the Firebase Token. (documentation https://firebase.google.com/docs/cloud-messaging/ios/client )

    func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
            // send to remote server
            InstanceID.instanceID().instanceID { result, error in
                if let error = error {
                    print("Error fetching remote instance ID: \(error)")
                } else if let result = result {
                    print("Remote instance ID token: \(result.token)")
                }
            }
        }
    

提交回复
热议问题