简体   繁体   中英

Why aren't my FCM notifications showing in iOS (flutter)

I am doing a flutter app that, when some users do some things, another users receive a push notification (From firebase messaging). In android it is working fine, but in iOS I can't do this work at all.

Thing I've done:

  • Generate a key in apple developers and import it in firebase APN
  • Turned on 'push notifications, Background Modes, Background fetch and Remote notifications in Xcode
  • Do the connection with firebase work (google service.plist)

In sum, All the connections with firebase are working in both android and iOS but in iOS the notifications doesn't appear.

The following code is from my AppDelegate.swift

import UIKit
import Flutter
import Firebase

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    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()
    FirebaseApp.configure()
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

There are some error on it? How could I fix the problem? If needed I can post other parts of the code.

Have you inserted:

<key>FirebaseScreenReportingEnabled</key>
<true/>
<key>FirebaseAppDelegateProxyEnabled</key>
<true/>

into info.plist?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM