0

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.

Miles Zoltak
  • 191
  • 11
  • Did you later solve this ? – Gbenga B Ayannuga Aug 15 '21 at 17:13
  • I wish! I'm still working through it. Hoping to get it soon, and I'll try to post back here if I get it working and can tell what the necessary change was. I've been throwing everything at the wall to see what sticks and it hasn't been working. This may be of interest to you though: https://stackoverflow.com/questions/64172280/flutter-fcm-on-ios-14 Hasn't worked yet for me tho @GbengaBAyannuga – Miles Zoltak Aug 16 '21 at 22:34
  • update your question with payload if is the same with my own – Gbenga B Ayannuga Aug 17 '21 at 09:26
  • @GbengaBAyannuga i have no idea what you mean by that but I solved my issue. You can find the post here https://stackoverflow.com/questions/69006236/do-i-need-apns-certificates-if-im-using-apns-auth-key?noredirect=1#comment121962328_69006236 – Miles Zoltak Sep 05 '21 at 19:18

0 Answers0