我尝试为我的flutter应用程序获取一个Firebase云消息传递令牌。哪个在android模拟器上运行这里出了什么问题?我尝试了flutter run
,但此方法不起作用,在这里我使用了 1.firebase_messaging:^ 6.0.9作为依赖项和 2。
import 'package:flutter/material.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
class Notifications_ extends StatefulWidget {
@override
_Notifications_State createState() => _Notifications_State();
}
class _Notifications_State extends State<Notifications_> {
final FirebaseMessaging _messaging=FirebaseMessaging();
@override
void initState() {
super.initState();
_messaging.getToken().then((token)
{
print(token);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('notification'),
),
body: Text('body testing'),
);
}
}
E/flutter ( 5931): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method getToken on channel plugins.flutter.io/firebase_messaging)
E / flutter(5931):#0 MethodChannel.invokeMethod(软件包:flutter / src / services / platform_channel.dart:319:7) E /颤振(5931): E / flutter(5931):#1 FirebaseMessaging.getToken(package:firebase_messaging / firebase_messaging.dart:150:27) E / flutter(5931):#2 _Notifications_State.initState(package:sampletestingpro / Notification.dart:17:16) E / flutter(5931):#3 StatefulElement._firstBuild(package:flutter / src / widgets / framework.dart:4355:58) E / flutter(5931):#4 ComponentElement.mount(包:flutter / src / widgets / framework.dart:4201:5) E / flutter(5931):#5 Element.inflateWidget(package:flutter / src / widgets / framework.dart:3194:14) E / flutter(5931):#6 Element.updateChild(包:flutter / src / widgets / framework.dart:2988:12) E / flutter(5931):#7 ComponentElement.performRebuild(package:flutter / src / widgets / framework.dart:4243:16) E / flutter(5931):#8 Element.rebuild(包:flutter / src / widgets / framework.dart:3947:5) E / flutter(5931):#9 StatelessElement.update(包:flutter / src / widgets / framework.dart:4298:5) E / flutter(5931):#10 Element.updateChild(package:flutter / src / widgets / framework.dart:2977:15) E / flutter(5931):#11 ComponentElement.performRebuild(package:flutter / src / widgets / framework.dart:4243:16) E / flutter(5931):#12 Element.rebuild(包:flutter / src / widgets / framework.dart:3947:5) E / flutter(5931):#13 StatelessElement.update(包:flutter / src / widgets / framework.dart:4298:5) E / flutter(5931):#14 Element.updateChild(包:flutter / src / widgets / framework.dart:2977:15) E / flutter(5931):#15 ComponentElement.performRebuild(package:flutter / src / widgets / framework.dart:4243:16) E / flutter(5931):#16 Element.rebuild(包:flutter / src / widgets / framework.dart:3947:5) E / flutter(5931):#17 ProxyElement.update(软件包:flutter / src / widgets / framework.dart:4557:5) E / flutter(5931):#18 Element.updateChild(包:flutter / src / widgets / framework.dart:2977:15) E / flutter(5931):#19 ComponentElement.performRebuild(package:flutter / src / widgets / framework.dart:4243:16) E / flutter(5931):#20 Element.rebuild(包:flutter / src / widgets / framework.dart:3947:5) E / flutter(5931):#21 ProxyElement.update(软件包:flutter / src / widgets / framework.dart:4557:5) E / flutter(5931):#22 Element.updateChild(包:flutter / src / widgets / framework.dart:2977:15) E / flutter(5931):#23 RenderObjectElement.updateChildren(package:flutter / src / widgets / framework.dart:5161:32) E / flutter(5931):#24 MultiChildRenderObjectElement.update(package:flutter / src / widgets / framework.dart:5561:17) E / flutter(5931):#25 Element.updateChild(包:flutter / src / widgets / framework.dart:2977:15) E / flutter(5931):#26 ComponentElement.performRebuild(包:flutter / src / widgets / framework.dart:4243:16) E / flutter(5931):#27 Element.rebuild(包:flutter / src / widgets / framework.dart:3947:5) E / flutter(5931):#28 StatefulElement.update(包:flutter / src / widgets / framework.dart:4413:5) E / flutter(5931):#29 Element.updateChild(包:flutter / src / widgets / framework.dart:2977:15) E / flutter(5931):#30 ComponentElement.performRebuild(package:flutter / src / widgets / framework.dart:4243:16) E / flutter(5931):#31 Element.rebuild(包:flutter / src / widgets / framework.dart:3947:5) E / flutter(5931):#32 ProxyElement.update(软件包:flutter / src / widgets / framework.dart:4557:5) E / flutter(5931):#33 Element.updateChild(包:flutter / src / widgets / framework.dart:2977:15) E / flutter(5931):#34 ComponentElement.performRebuild(package:flutter / src / widgets / framework.dart:4243:16) E / flutter(5931):#35 Element.rebuild(包:flutter / src / widgets / framework.dart:3947:5) E / flutter(5931):#36 StatefulElement.update(包:flutter / src / widgets / framework.dart:4413:5) E / flutter(5931):#37 Element.updateChild(包:flutter / src / widgets / framework.dart:2977:15) E / flutter(5931):#38 SingleChildRenderObjectElement.update(package:flutter / src / widgets / framework.dart:5452:14) E / flutter(5931):#39 Element.updateChild(包:flutter / src / widgets / framework.dart:2977:15) E / flutter(5931):#40 ComponentElement.performRebuild(包:flutter / src / widgets / framework.dart:4243:16) E / flutter(5931):#41 Element.rebuild(包:flutter / src / widgets / framework.dart:3947:5) E / flutter(5931):#42 StatelessElement.update(包:flutter / src / widgets / framework.dart:4298:5) E / flutter(5931):#43 Element.updateChild(包:flutter / src / widgets / framework.dart:2977:15) E / flutter(5931):#44 SingleChildRenderObjectElement.update(package:flutter / src / widgets / framework.dart:5452:14) E / flutter(5931):#45 Element.update。
答案 0 :(得分:2)
答案 1 :(得分:0)