Firebase instanceID token deprecated

Dear Sir;

I’m trying to get an instance for FIRInstanceID by using swift 5. currently the syntax

InstanceID.instanceID().token is deprecated so how can I create an instance now ?

Regards
Samer

Hi @samerhameed, this has worked for me recently

InstanceID.instanceID().instanceID { (result, error) in
        if let error = error {
            print("Error:  \(error)")
        } else if let result = result {
            print("Remote instance: \(result.token)")
        }
    }
1 Like

Hi @gdelarosa
yes thank you a lot, you saved me

Regards

The way in which we were getting the device registration token to use a Firebase Cloud Messaging client App on Android has changed and now is deprecated, thus we need to do a simple fix to avoid some headaches in the near future when the getToken() method is not longer supported.

FirebaseInstanceId.getInstance().getToken()

But as mentioned before getInstance().getToken is deprecated and now we need to replace it with a listener as follows:

The previous code was taken from the sample app and you can take a look there, but that is all. Is a simple fix and an easy way to ensure the support of the new capabilities of FCM.

This topic was automatically closed after 166 days. New replies are no longer allowed.