简体   繁体   English

Firebase 通知:如何从 Firebase 中删除令牌?

[英]Firebase notification: How to delete token from Firebase?

I am using Firebase messaging services for push notification in my iOS app.我在我的 iOS 应用程序中使用 Firebase 消息传递服务进行推送通知。 I am trying to delete the registered token from firebase using the following method.我正在尝试使用以下方法从 firebase 中删除注册的令牌。

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.这个函数的预期输出应该是什么,因为我没有得到任何关于设备未从 FCM 注册的确认。 I am passing GCM_SENDER_ID as AuthorizedEntity.我将GCM_SENDER_ID作为 AuthorizedEntity 传递。 Can anyone help??有人可以帮忙吗??

Revokes access to a scope (action) for an entity previously authorized by [FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler] . [FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]对先前由[FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]授权的实体的范围(操作)的访问权限。 This is an asynchronous call.这是一个异步调用。 So, call this on the main thread since InstanceID lib is not thread safe.因此,在主线程上调用它,因为 InstanceID lib 不是线程安全的。 Note, you can only have one token or deleteToken call for a given authorizedEntity and scope at a point of time.请注意,在某个时间点,您只能对给定的授权deleteToken和范围使用一个tokendeleteToken调用。

Hope,it helps.希望能帮助到你。

Kotlin Code科特林代码

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM