未处理的异常:IOS中的MissingPluginException(在通道plugins.flutter.io/firebase_messaging上未找到方法getToken的实现)

时间:2020-06-23 23:23:19

标签: ios flutter firebase-cloud-messaging

在IOS模拟器中运行我的应用程序时,出现此错误: 有人知道为什么吗?

顺便说一句,它适用于Android。

enter image description here

这里有一些示例代码:

AppDelegate.swift

import UIKit
import Flutter

@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
    }
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }

获取令牌的方法

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

0 个答案:

没有答案