gpt4 book ai didi

firebase - 未处理的异常 : MissingPluginException(No implementation found for method getToken on channel plugins. flutter.io/firebase_messaging)

转载 作者:行者123 更新时间:2023-12-03 02:55:41 25 4
gpt4 key购买 nike

我尝试将 firebase 云消息传递 token 发送到我的 flutter 应用程序。哪个在 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 (package:flutter/src/services/platform_channel.dart:319:7) E/flutter ( 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 (package: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 (package: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 (package:flutter/src/widgets/framework.dart:3947:5) E/flutter ( 5931): #9 StatelessElement.update (package: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 (package:flutter/src/widgets/framework.dart:3947:5) E/flutter ( 5931): #13 StatelessElement.update (package:flutter/src/widgets/framework.dart:4298:5) E/flutter ( 5931): #14 Element.updateChild (package: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 (package:flutter/src/widgets/framework.dart:3947:5) E/flutter ( 5931): #17 ProxyElement.update (package:flutter/src/widgets/framework.dart:4557:5) E/flutter ( 5931): #18 Element.updateChild (package: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 (package:flutter/src/widgets/framework.dart:3947:5) E/flutter ( 5931): #21 ProxyElement.update (package:flutter/src/widgets/framework.dart:4557:5) E/flutter ( 5931): #22 Element.updateChild (package: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 (package:flutter/src/widgets/framework.dart:2977:15) E/flutter ( 5931): #26 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16) E/flutter ( 5931): #27 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5) E/flutter ( 5931): #28 StatefulElement.update (package:flutter/src/widgets/framework.dart:4413:5) E/flutter ( 5931): #29 Element.updateChild (package: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 (package:flutter/src/widgets/framework.dart:3947:5) E/flutter ( 5931): #32 ProxyElement.update (package:flutter/src/widgets/framework.dart:4557:5) E/flutter ( 5931): #33 Element.updateChild (package: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 (package:flutter/src/widgets/framework.dart:3947:5) E/flutter ( 5931): #36 StatefulElement.update (package:flutter/src/widgets/framework.dart:4413:5) E/flutter ( 5931): #37 Element.updateChild (package: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 (package:flutter/src/widgets/framework.dart:2977:15) E/flutter ( 5931): #40 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16) E/flutter ( 5931): #41 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5) E/flutter ( 5931): #42 StatelessElement.update (package:flutter/src/widgets/framework.dart:4298:5) E/flutter ( 5931): #43 Element.updateChild (package: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.

最佳答案

**Keep the google JSON service file inside the app folder,**

将 google JSON 服务文件保存在 app 文件夹中,我错误地将 JSON 文件放在 src/文件夹中,这就是我收到错误的原因

关于firebase - 未处理的异常 : MissingPluginException(No implementation found for method getToken on channel plugins. flutter.io/firebase_messaging),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60208984/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com