I've been struggling with iOS push notifications on Flutter via FCM for a LONG time. It seems like it was a lot more complicated before the latest big updates to flutter and firebase, but I'm not really sure exactly what has changed.
I am receiving notifications on Android, so I am assuming my issue lies in the special iOS setup with APNs, but the exact issue is still eluding me.
I've followed all the special iOS steps (except for image payload stuff, bc I don't need it). I moved from a virtual machine to a real one a week or two ago, and I redid all the certificate/key/profile/identifier stuff thinking maybe the issue was signing with a different machine, but that didn't fix it. I also am not not "Automatically managing signing" (under "Signing & Capabilities" in xcode). I have enabled Background Modes and Remote notifications. Notifications are turned on for the testflight app on the PHYSICAL iOS device I am using.
I have the following code in my AppDelegate.swift file:
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
//for push notifications
if #available(iOS 10.0, *) {
//for ios 10 display notification sent via APNS
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions, completionHandler: {_, _ in })
} else {
let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
I also have the following line in my Info.plist file (not the exact formatting, but y'know what an info.plist file looks like):
FirebaseAppDelegateProxyEnabled: NO
Additionally, I know that FCM is at least partially integrated, because my iOS apps are getting a FCM notification token that is getting written to my database. However, when I send messages from the FCM console, they never arrive on the iOS device (foreground OR background).
I really don't know what's going on. But I've been pulling my hair out. Any help would be appreciated.