【问题标题】:Unhandled Exception: MissingPluginException(No implementation found for method ****** on channel plugins.flutter.io/firebase_messaging) on IOS未处理的异常:IOS 上的 MissingPluginException(未找到通道 plugins.flutter.io/firebase_messaging 上的方法 ****** 的实现)
【发布时间】:2025-11-22 06:50:02
【问题描述】:

我在 IOS 中使用 FCM 插件时遇到了这些错误,有人知道为什么以及如何解决这个问题吗? 顺便说一句,它适用于 Android。

════════════════════════════════════════════════════════════════════════════════════════════════════
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method requestNotificationPermissions on channel plugins.flutter.io/firebase_messaging)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
<asynchronous suspension>
#1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
#2      FirebaseMessaging.requestNotificationPermissions (package:firebase_messaging/firebase_messaging.dart:87:21)
#3      _HomeState.getIOSPermission (package:in_jesus_name/screens//home.dart:153:24)
#4      _HomeState.configurePushNotificationsFirebaseUser (package:in_jesus_name/screens//home.dart:227:7)
<asynchronous suspension>
#5      _HomeState.handleFirebaseSignIn (package:in_jesus_name/screens//home.dart:143:9)
<asynchronous suspension>
#6      _HomeState.initState.<anonymous closure> (package:in_jesus_name/screens//home.dart:822:7)
#7      _rootRunUnary (dart:async/zone.dart:1192:38)
#8  <…>
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method getToken on channel plugins.flutter.io/firebase_messaging)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
<asynchronous suspension>
#1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
#2      FirebaseMessaging.getToken (package:firebase_messaging/firebase_messaging.dart:150:27)
#3      _HomeState.configurePushNotificationsFirebaseUser (package:in_jesus_name/screens//home.dart:245:24)
#4      _rootRunUnary (dart:async/zone.dart:1192:38)
#5      _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#6      _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#7      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#8      Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#9      Future._completeWithValue (dart:async/future_impl.dart:526:5)
<…>
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method configure on channel plugins.flutter.io/firebase_messaging)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
<asynchronous suspension>
#1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
#2      FirebaseMessaging.configure (package:firebase_messaging/firebase_messaging.dart:114:14)
#3      _HomeState.configurePushNotificationsFirebaseUser (package:in_jesus_name/screens//home.dart:250:24)
#4      _rootRunUnary (dart:async/zone.dart:1192:38)
#5      _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#6      _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#7      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#8      Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#9      Future._completeWithValue (dart:async/future_impl.dart:526:5<…>

这里是这些错误来自的代码示例:

[VERBOSE-2:ui_dart_state.cc(157)] 未处理异常:MissingPluginException(未找到通道 plugins.flutter.io/firebase_messaging 上的方法 requestNotificationPermissions 的实现)

getIOSPermission() {
    _firebaseMessaging.requestNotificationPermissions(
        IosNotificationSettings(alert: true, badge: true, sound: true));
    _firebaseMessaging.onIosSettingsRegistered.listen((settings) {
      print("Settings registered:$settings");
    });
  }

[VERBOSE-2:ui_dart_state.cc(157)] 未处理的异常:MissingPluginException(在通道 plugins.flutter.io/firebase_messaging 上找不到方法 getToken 的实现)

_firebaseMessaging.getToken().then((token) {
  print("Firebase Messaging Token: $token\n");
  usersRef.document(firebaseUser.uid).updateData({"FCMToken": token});
});

[VERBOSE-2:ui_dart_state.cc(157)] 未处理的异常:MissingPluginException(未找到通道 plugins.flutter.io/firebase_messaging 上的方法配置的实现)

_firebaseMessaging.configure(
      onLaunch: onPush,
      onResume: onPush,
      onMessage: onPush,
      onBackgroundMessage: Platform.isIOS ? null :onBackgroundPush,
    );
 }

这是我的 AppDelegate.swift:

import UIKit
import Flutter
import Firebase

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    if #available(iOS 10.0, *) {
      UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
    }
    FirebaseApp.configure()
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }

}

我已经按照https://pub.dev/packages/firebase_messaging 中指定的所有步骤进行 IOS 集成: APNs 和所有...有人知道如何解决这个问题吗?

【问题讨论】:

  • 在终端中运行:'flutter doctor',如果输出中有任何问题,请添加到您的问题中

标签: ios flutter firebase-cloud-messaging


【解决方案1】:

我刚刚找到了我的问题的解决方案,我遇到了这些错误,因为我在我的项目中添加了颤振 apns 插件,它禁用了 fcm 插件。 删除它解决了我的问题。

【讨论】:

  • 大声笑,无论出于何种原因,我也安装了这个插件。可能在 Firebase Messaging 出现其他问题时安装了它......这些插件真的可以毁了你的一天。谢谢!
  • 请提供更多信息,您需要删除什么?
  • 请提供有关如何删除违规插件的分步说明。
  • 进入您的 pubspec.yaml 文件,您应该会找到您添加的 Flutter apn 包。只需删除添加它的行。
最近更新 更多