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

前端 未结 15 2016
日久生厌
日久生厌 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:14

    The recommended way by Firebase:

    let token = Messaging.messaging().fcmToken
    

    Reference : Setting Up a Firebase Cloud Messaging Client App on iOS

    0 讨论(0)
  • 2021-01-31 03:14

    To Get current FCM Token

    if let token = Messaging.messaging().fcmToken {
        // token is current fcmToken
    }
    

    To Renew current FCM Token

    If we delete current instanceId, new token will be received vi MessagingDelegate (messaging:didReceiveRegistrationToken) a moment later.

    InstanceID.instanceID().deleteID { (error) in
        if let er = error {
            print(er.localizedDescription)
        } else {
            print("instanceID().deleteID  success ---------------➤")
        }
    }
    
    0 讨论(0)
  • 2021-01-31 03:18

    FCM Device Token swift3

        let fcmDeviceToken = FIRInstanceID.instanceID().token()
        print("FCM token: \(fcmDeviceToken ?? "")")
    
    0 讨论(0)
提交回复
热议问题