微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

未处理的异常:MissingPluginException在频道 dexterous.com/flutter/local_notifications 上找不到方法显示的实现

如何解决未处理的异常:MissingPluginException在频道 dexterous.com/flutter/local_notifications 上找不到方法显示的实现

我面临 Flutter2 和本地通知插件的问题。当应用程序在前台时 - 本地通知工作正常,但当应用程序在后台时 - 我收到 MissingPluginException 错误

E/Flutter (18894): [ERROR:Flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method show on channel dexterous.com/Flutter/local_notifications)
E/Flutter (18894): #0      MethodChannel._invokeMethod (package:Flutter/src/services/platform_channel.dart:156:7)
E/Flutter (18894): <asynchronous suspension>
E/Flutter (18894): #1      FlutterlocalnotificationsPlugin.show (package:Flutter_local_notifications/src/Flutter_local_notifications_plugin.dart:179:7)
E/Flutter (18894): <asynchronous suspension>

我的发布规范:

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  Flutter:
    sdk: Flutter

  Flutter_local_notifications: ^5.0.0+4

# firebase
  firebase_core: ^1.0.1
  firebase_auth: ^1.0.3
  cloud_firestore: ^1.0.4
  firebase_storage: ^8.0.3
  firebase_messaging: ^9.1.1
  firebase_core_platform_interface: ^4.0.0
  firebase_analytics: ^7.0.0
  firebase_dynamic_links: ^0.8.0
  firebase_crashlytics: ^2.0.3

还有我的 MainActivity 文件

import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle
import android.os.PersistableBundle
import com.dexterous.Flutterlocalnotifications.FlutterlocalnotificationsPlugin
import io.Flutter.embedding.android.FlutterActivity
import io.Flutter.embedding.engine.FlutterEngine
import io.Flutter.plugin.common.MethodCall
import io.Flutter.plugin.common.MethodChannel
import io.Flutter.plugin.common.PluginRegistry
import io.Flutter.plugins.FirebaseCloudMessagingPluginRegistrant
import io.Flutter.plugins.GeneratedpluginRegistrant
import io.Flutter.plugins.firebase.messaging.FlutterFirebaseMessagingBackgroundService
import zendesk.core.Zendesk


class MainActivity : FlutterActivity() {

    override fun onCreate(savedInstanceState: Bundle?,persistentState: PersistableBundle?) {
        super.onCreate(savedInstanceState,persistentState)
    }


    override fun configureFlutterEngine(FlutterEngine: FlutterEngine) {
        super.configureFlutterEngine(FlutterEngine)
        MethodChannel(FlutterEngine.dartExecutor.binaryMessenger,channelName).setMethodCallHandler { call,result ->
            if (call.method == "start") {
                start(call,result)
            } else {
            }
        }
    }

}

我还发现应用启动时出现警告:

I/FLTFireBGExecutor(21072): Creating background FlutterEngine instance,with args: [--start-paused,--enable-dart-profiling]
W/FlutterEngine(21072): Tried to automatically register plugins with FlutterEngine (io.Flutter.embedding.engine.FlutterEngine@b3b4ecc) but Could not find and invoke the GeneratedpluginRegistrant.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。