简体   繁体   中英

Firebase iOS notification - Flutter

I have the following error:

W0210 18:59:44.855086       1 commandlineflags.cc:1503] Ignoring RegisterValidateFunction() for flag pointer 0x102ff2690: no flag found at that address
2020-02-10 18:59:44.919282-0300 Runner[369:11564] Metal GPU Frame Capture Enabled
2020-02-10 18:59:44.919645-0300 Runner[369:11564] Metal API Validation Enabled
2020-02-10 18:59:45.040087-0300 Runner[369:11564] Configuring the default Firebase app...
2020-02-10 18:59:45.040489-0300 Runner[369:11759] 6.15.0 - [Firebase/Core][I-COR000004] App with name __FIRAPP_DEFAULT does not exist.
2020-02-10 18:59:45.083458-0300 Runner[369:11753] 6.15.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60201000 started
2020-02-10 18:59:45.084531-0300 Runner[369:11753] 6.15.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2020-02-10 18:59:45.088137-0300 Runner[369:11564] Configured the default Firebase app __FIRAPP_DEFAULT.
2020-02-10 18:59:45.089221-0300 Runner[369:11564] *** Terminating app due to uncaught exception 'com.firebase.core', reason: 'Default app has already been configured.'
*** First throw call stack:
(0x18b6f896c 0x18b411028 0x18b5e814c 0x10275ec78 0x10275e77c 0x10275e4fc 0x10275e448 0x102759ac4 0x102759e40 0x18f7efc18 0x18f7f1a14 0x18f7f7340 0x18ef8fbec 0x18f441518 0x18ef90724 0x18ef90154 0x18ef90540 0x18ef8fdc4 0x18ef94544 0x18f45b39c 0x18f36d7bc 0x18f45b354 0x18ef9425c 0x18f45b23c 0x18ef940b8 0x18edfc434 0x18edfaef8 0x18edfc164 0x18f7f5730 0x18f38f6bc 0x1908ede10 0x190914aa0 0x1908f8ef4 0x190914734 0x105ca327c 0x105ca69a4 0x19093b254 0x19093af00 0x19093b46c 0x18b674108 0x18b67405c 0x18b6737c8 0x18b66e694 0x18b66df40 0x1958fe534 0x18f7f9580 0x10275a030 0x18b4ece18)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

I'm trying to use Firebase notifications, my main iOS class looks like this:

import UIKit
import Flutter
import GoogleMaps
import Firebase

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GMSServices.provideAPIKey("AIzaSyDP9fqWxg-sxX5Ke66OuiSLM4WNFTZcy-g")
    GeneratedPluginRegistrant.register(with: self)
    FirebaseApp.configure()
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

I'm not trying to use backgroundMessage in the app. On Android it's working, but on iOS the application closes.

If you see the official documentation of the FCM Flutter Plugin you'll notice on the IOS Integration:

Don't follow the steps named "Add Firebase SDK" and "Add initialization code" in the Firebase assistant.

So you don't need to put on your AppDelegate:

import Firebase

neither

FirebaseApp.configure()

Don't know for sure if this is the origin of the problem but for me worked without those lines.

2021 Update: You don't need any change on the AppDelegate anymore. The new documentation is great and covers every aspect.

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