FirebaseInstanceIdService 已弃用 [英] FirebaseInstanceIdService is deprecated

查看:126
本文介绍了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 已弃用

有人知道吗?,我应该使用什么方法或类而不是这个来获取刷新的令牌,因为它已被弃用.

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,

和以前一样,当我问这个问题时,文档没有更新,但现在谷歌文档更新了,所以要了解更多信息,请参阅这个谷歌文档:FirebaseMessagingService

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 here

查看参考文档,了解FirebaseInstanceIdService:

该类已被弃用.

支持覆盖 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天全站免登陆