iAnurag
iAnurag

Reputation: 9356

Firebase notification: How to delete token from Firebase?

I am using Firebase messaging services for push notification in my iOS app. I am trying to delete the registered token from firebase using the following method.

FIRInstanceID.instanceID().deleteToken(withAuthorizedEntity: GCM_SENDER_ID, scope: kFIRInstanceIDScopeFirebaseMessaging, handler: { (result) in

   // What should be the expected result ???               

}) 

What should be the expected output from this function as I am not getting any acknowledgment that device is unregistered from FCM. I am passing GCM_SENDER_ID as AuthorizedEntity. Can anyone help??

Upvotes: 2

Views: 7750

Answers (2)

Sagar Chapagain
Sagar Chapagain

Reputation: 1763

Kotlin Code

FirebaseMessaging.getInstance().deleteToken().addOnCompleteListener { task ->
            if (task.isSuccessful) {
                // do something
            } else {
                // do something
            }
        }

Upvotes: 0

Arpit Jain
Arpit Jain

Reputation: 1690

Revokes access to a scope (action) for an entity previously authorized by [FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]. This is an asynchronous call. So, call this on the main thread since InstanceID lib is not thread safe. Note, you can only have one token or deleteToken call for a given authorizedEntity and scope at a point of time.

Hope,it helps.

Upvotes: 2

Related Questions