且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

颤抖:fcm ios推送通知在发布模式下不起作用

更新时间:2023-01-02 22:40:18

我的项目遇到了同样的问题.结合我发现的两个解决方案,它终于可以工作了.(firebase_messaging 7.0.3)

My project got the same issue. Combined two solutions I found, it finally works. (firebase_messaging 7.0.3)

对于调试模式,您不需要这些.

As for debug mode, you don't need these.

第1步:编辑AppDelegate.swift

Step 1: Edit 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)

    application.registerForRemoteNotifications()

    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

第2步:编辑ios/Runner/Info.plist.添加此内容:

Step 2: Edit ios/Runner/Info.plist. Add this:

<key>FirebaseAppDelegateProxyEnabled</key>
<string>NO</string>