[英]I'm using firebase messaging in my flutter app but when I run my project it show Stringtoken=FirebaseInstanceId.getInstance().getToken(senderId, "*");
I'm using firebase messaging in my flutter app but when I run my project it show String token = FirebaseInstanceId.getInstance().getToken(senderId, "*");我在我的 flutter 应用程序中使用 firebase 消息,但是当我运行我的项目时它显示 String token = FirebaseInstanceId.getInstance().getToken(senderId, "*");
when I run my application it shows this error in the console:当我运行我的应用程序时,它在控制台中显示此错误:
C:\Users\cerbi\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:166: error: cannot find symbol String token = FirebaseInstanceId.getInstance().getToken(senderId, "*"); C:\Users\cerbi\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java :166: 错误:找不到符号 String token = FirebaseInstanceId.getInstance().getToken(senderId, "*"); ^ symbol: variable FirebaseInstanceId location: class FlutterFirebaseMessagingPlugin Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details.
^ 符号:变量 FirebaseInstanceId 位置:class FlutterFirebaseMessagingPlugin 注意:一些输入文件使用或覆盖已弃用的 API。注意:使用 -Xlint:deprecation 重新编译以获取详细信息。
What went wrong: Execution failed for task ':firebase_messaging:compileDebugJavaWithJavac'.出了什么问题:任务“:firebase_messaging:compileDebugJavaWithJavac”的执行失败。
and when I navigate to the specific file stated in the error message here is the code in there当我导航到错误消息中所述的特定文件时,这里是其中的代码
private Task<Map<String, Object>> getToken(Map<String, Object> arguments) {
return Tasks.call(
cachedThreadPool,
() -> {
String senderId =
arguments.get("senderId") != null
? (String) arguments.get("senderId")
: Metadata.getDefaultSenderId(FirebaseApp.getInstance());
String token = FirebaseInstanceId.getInstance().getToken(senderId, "*");
return new HashMap<String, Object>() {
{
put("token", token);
}
};
});
}
What can I do to resolve this problem, it seems that the existing code is not working anymore我该怎么做才能解决这个问题,现有代码似乎不再起作用了
You should use你应该使用
FirebaseMessaging.getInstance().token
to get token, since获得令牌,因为
FirebaseInstanceId.getInstance().getToken
is deprecated.已弃用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.