flutter: fcm ios push notifications doesn't work in release mode
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.
Step 1: Edit AppDelegate.swift
import UIKitimport 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) }}
Step 2: Edit ios/Runner/Info.plist. Add this:
<key>FirebaseAppDelegateProxyEnabled</key><string>NO</string>
After update firebase_messaging to 7.0.0 I had the same problem. I added application.registerForRemoteNotifications() in my AppDelegate.swift and it worked!
I have the same issue. Looks like iOS release require additional notification params
To check that notification works you could try to send message directly from the firebase console.
Cloud Messaging -> Send your first message -> Enter notification title and text -> Send test message -> Enter your device token -> Test
To obtain device token you can use print(await FirebaseMessaging().getToken());
To check release logs connect the device and open Xcode -> Window -> Devices and Simulators -> Open Console
If it works you could try to add this params:
const payload = { notification: { title: newData.title, body: newData.body, sound: 'default' }, data: { click_action: 'FLUTTER_NOTIFICATION_CLICK', message: newData.title, }, apns: { headers: { "apns-priority": "5" }, payload: { aps: { contentAvailable: true, category: "NEW_MESSAGE_CATEGORY" } } },};
But I'm not sure which param helps: "apns-priority"
or contentAvailable
.