不推荐使用FirebaseInstanceIdService [英] FirebaseInstanceIdService is deprecated

查看:175
本文介绍了不推荐使用FirebaseInstanceIdService的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望大家都知道这个类,用于在刷新Firebase通知令牌时获取通知令牌,我们从此类中从以下方法中获取刷新的令牌.

Hope all of you aware of this class, used to get notification token whenever firebase notification token got refreshed we get the refreshed token from this class, From following method.

@Override
public void onTokenRefresh() {
    // Get updated InstanceID token.
    String refreshedToken = FirebaseInstanceId.getInstance().getToken();
    Log.d(TAG, "Refreshed token: " + refreshedToken);
}

要在实现FCM时使用它,我从FirebaseInstanceIdService

To use this as i want to implement FCM, I extended MyClass from FirebaseInstanceIdService

但是,表明不赞成使用 FirebaseInstanceIdService

But, Showing that FirebaseInstanceIdService is deprecated

有人知道吗?, 我不建议使用什么方法或类代替它来获取刷新的令牌.

Does anybody know this?, What method or class i should use instead of this to get refreshed token as this is deprecated.

我正在使用:implementation 'com.google.firebase:firebase-messaging:17.1.0'

我检查了文档是否相同,对此没有提及. : FCM设置文档

I checked the document for same there is nothing mentioned about this. : FCM SETUP DOCUMENT

更新

此问题已得到解决.

Google弃用了FirebaseInstanceService

As Google deprecated the FirebaseInstanceService,

我问了问题以找到方法,我知道我们可以从 FirebaseMessagingService 获取令牌,

I asked the question to find the way and i get to know that We can get the Token from FirebaseMessagingService,

和以前一样,当我问问题文档未更新但现在Google文档已更新以便获取更多信息时,请参阅此google文档:

As before, when i asked the Question Documents were not updated but Now Google docs updated so for more info, Refer this google doc : FirebaseMessagingService

旧发件人:FirebaseInstanceService(已弃用)

@Override
public void onTokenRefresh() {
    // Get updated InstanceID token.
    String refreshedToken = FirebaseInstanceId.getInstance().getToken();
    Log.d(TAG, "Refreshed token: " + refreshedToken);
}

新来自:FirebaseMessagingService

@Override
public void onNewToken(String s) {
    super.onNewToken(s);
    Log.d("NEW_TOKEN",s);
}

谢谢.

推荐答案

firebaser此处

查看 FirebaseInstanceIdService的参考文档 a>:

Check the reference documentation for FirebaseInstanceIdService:

不推荐使用此类.

This class was deprecated.

赞成覆盖FirebaseMessagingService中的onNewToken.一旦实施,就可以安全地删除此服务.

In favour of overriding onNewToken in FirebaseMessagingService. Once that has been implemented, this service can be safely removed.

奇怪的是,FirebaseMessagingService的JavaDoc还没有提到onNewToken方法.似乎尚未发布所有更新的文档.我提出了一个内部问题,以获取对参考文档的更新,并也对指南中的示例进行了更新.

Weirdly enough the JavaDoc for FirebaseMessagingService doesn't mention the onNewToken method yet. It looks like not all updated documentation has been published yet. I've filed an internal issue to get the updates to the reference docs published, and to get the samples in the guide updated too.

与此同时,旧的/已弃用的呼叫和新的呼叫均应正常工作.如果您遇到任何麻烦,请发布代码,然后看看.

In the meantime both the old/deprecated calls, and the new ones should work. If you're having trouble with either, post the code and I'll have a look.

这篇关于不推荐使用FirebaseInstanceIdService的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆