Is there an existing issue for this?
Are you aware of the differences between iOS and Android background message handling?
Do you have an active Apple Developer account?
Are you using a physical iOS device to test background messages?
Have you enabled "Remote Notifications" & "Background Mode" (Checking options for "Background Processing" & "Remote Notifications") in your app's Xcode project?
Yes
Have you created an APNs key in your Apple Developer account & uploaded this APNs key to your Firebase console?
Yes
Have you disabled method swizzling for Firebase in your app?
Yes
Are you sending messages to your app from the Firebase Admin SDK?
admin
.messaging()
.sendToDevice(
[token],
{
"senderId":null,
"category":null,
"collapseKey":null,
"contentAvailable":true,
"data":{
"visits":[
{
"status":"new",
"duration":"15:30\u201416:15",
"serviceName":"Service name"
},
],
"userID":64881,
"clickAction":"FLUTTER_NOTIFICATION_CLICK",
"visitID":2500300,
"notificationCount":78,
"type":"visits",
"sound":"default",
"url":"/cabinet/visits/2500300"
},
"from":null,
"messageId":1781255183960138,
"messageType":null,
"mutableContent":true,
"notification":{
"title":"Новая запись",
"titleLocArgs":[
],
"titleLocKey":null,
"body":"15 июня в 17":"00 Услуга":"SPA":"Массаж",
"bodyLocArgs":[
],
"bodyLocKey":null,
"android":null,
"apple":{
"badge":null,
"subtitle":null,
"subtitleLocArgs":[
],
"subtitleLocKey":null,
"imageUrl":"",
"sound":{
"critical":false,
"name":"default",
"volume":1
}
},
"web":null
},
"sentTime":null,
"threadId":null,
"ttl":null
}
)
Have you requested permission from the user to receive notifications?
Have you used the 'Console' application on your macOS device to check if the iOS device's system is throttling your background messages?
Yes. But didReceiveRemoteNotification not called.
Additional context and comments
Missing handling call _firebaseMessagingBackgroundHandler callback after migrating to flutter v3.44+.
Before Flutter v3.44+, everything worked with the current payload.
My AppDelegate
import UIKit
import Flutter
import Firebase
import FirebaseMessaging
import UserNotifications
@main
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate, MessagingDelegate {
override func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
UNUserNotificationCenter.current().delegate = self
application.registerForRemoteNotifications()
UIApplication.shared.setMinimumBackgroundFetchInterval(TimeInterval(60*15))
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
}
override func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
}
override func application(
_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
) {
print("FCM didReceiveRemoteNotification | state=\(application.applicationState.rawValue) userInfo=\(userInfo)")
Messaging.messaging().appDidReceiveMessage(userInfo)
// Handle the notification natively since Flutter's handler doesn't work
if let type = userInfo["type"] as? String, type == "visits" {
print("FCM didReceiveRemoteNotification | Received 'visits' notification, processing natively")
// Process notification here
// completionHandler(.newData)
// return
}
super.application(
application,
didReceiveRemoteNotification: userInfo,
fetchCompletionHandler: completionHandler
)
}
// If APNs registration fails, display an error message.
override func application(_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("APNs register failed: \(error)")
super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
}
// Call when a notification is delivered to a foreground app.
override func userNotificationCenter(
_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
) {
let userInfo = notification.request.content.userInfo
Messaging.messaging().appDidReceiveMessage(userInfo)
super.userNotificationCenter(center, willPresent: notification) { options in
if #available(iOS 14.0, *) {
completionHandler(options.union([.banner, .list, .sound]))
} else {
completionHandler(options.union([.alert, .sound]))
}
}
}
}
Is there an existing issue for this?
Are you aware of the differences between iOS and Android background message handling?
Do you have an active Apple Developer account?
Are you using a physical iOS device to test background messages?
Have you enabled "Remote Notifications" & "Background Mode" (Checking options for "Background Processing" & "Remote Notifications") in your app's Xcode project?
Yes
Have you created an APNs key in your Apple Developer account & uploaded this APNs key to your Firebase console?
Yes
Have you disabled method swizzling for Firebase in your app?
Yes
Are you sending messages to your app from the Firebase Admin SDK?
Have you requested permission from the user to receive notifications?
Have you used the 'Console' application on your macOS device to check if the iOS device's system is throttling your background messages?
Yes. But didReceiveRemoteNotification not called.
Additional context and comments
Missing handling call _firebaseMessagingBackgroundHandler callback after migrating to flutter v3.44+.
Before Flutter v3.44+, everything worked with the current payload.
My AppDelegate