不再使用FirebaseInstanceId,而是使用FirebaseInstallations和FirebaseMessaging
创始人
2025-01-11 16:00:08
0

FirebaseInstanceId在2020年底被宣布将被废弃,因此建议使用FirebaseInstallations和FirebaseMessaging代替。FirebaseInstallations提供了生成和管理FIS IDs的能力,而FirebaseMessaging可用于发送消息到指定的应用程序实例。

以下是一个示例代码:

// Initialize FirebaseInstallations FirebaseInstallations.getInstance().getId() .addOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { if (task.isSuccessful()) { String fisId = task.getResult(); Log.d(TAG, "Firebase Installations ID: " + fisId); // Use the FIS ID to send messages to the app instance } else { Log.e(TAG, "Failed to get Firebase Installations ID", task.getException()); } } });

// Initialize FirebaseMessaging FirebaseMessaging.getInstance().getToken() .addOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { if (task.isSuccessful()) { String token = task.getResult(); Log.d(TAG, "Firebase Messaging Token: " + token); } else { Log.e(TAG, "Failed to get Firebase Messaging Token", task.getException()); } } });

可以在应用程序的build.gradle文件中添加以下依赖项:

implementation 'com.google.firebase:firebase-installations:17.0.0' implementation 'com.google.firebase:firebase-messaging:22.0.0'

相关内容

热门资讯

透视app!wpk透视脚本链接... 透视app!wpk透视脚本链接,aapoker透视插件,可靠教程(往昔存在有挂)1、点击下载安装,微...
透视教学!智星德州菠萝透视插件... 透视教学!智星德州菠萝透视插件工具,hhpoker开挂教程,第三方教程(起初是真的有挂)1、完成智星...
透视安卓版!智星菠萝辅助,如何... 透视安卓版!智星菠萝辅助,如何下载wpk透视版,新版2025教程(真是存在有挂),亲,有的,ai轻松...
透视新版!wepoker透视脚... 透视新版!wepoker透视脚本下载,wepoker透视app下载,透明挂教程(一向是真的有挂);人...
透视肯定!aapoker辅助插... 《透视肯定!aapoker辅助插件工具,wpk辅助哪里买,德州教程(从前真的有挂)》 aapoker...
透视计算!德普之星辅助器app... 透视计算!德普之星辅助器app,wepoker透视脚本是什么,攻略教程(原生有挂);是一款可以让一直...
透视有挂!hhpoker辅助软... 透视有挂!hhpoker辅助软件下载,约局吧辅助器,详细教程(最初是真的有挂);原来确实真的有挂(需...
透视好友房!wpk辅助工具,h... 透视好友房!wpk辅助工具,hhpoker开挂教程,安装教程(好像真的是有挂)是一款可以让一直输的玩...
透视存在!红龙poker脚本,... 红龙poker脚本新手教程相关信息汇总(需添加指定Q群1067239143获取下载链接);透视存在!...
透视总结!wepoker透视脚... 透视总结!wepoker透视脚本安卓,wepoker作弊方法,可靠教程(果然真的是有挂);科技详细教...