Необработанное исключение: 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>

Мой pubspec:

      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.

0 ответов

Другие вопросы по тегам