从我对FirebaseApp.configure()的调用中似乎收到了错误消息“尚未配置默认Firebase应用程序”;这是我的代码:
func configPushNotifications() {
NSLog("\(TAG) in configPushNotifications")
FirebaseApp.configure()
NSLog("\(TAG) called FirebaseApp.configure()")
Messaging.messaging().delegate = self
NSLog("\(TAG) set msg'ing delegate")
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })
}
UIApplication.shared.registerForRemoteNotifications()
NSLog("\(TAG) called registerForRemoteNotifications")
}
...以及生成的日志:
2019-12-02 16:28:27.375255-0500 rMove[541:62736] _PH_ in configPushNotifications
2019-12-02 16:28:27.398807-0500 rMove[541:62982] 6.10.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: [shortened URL here].
2019-12-02 16:28:27.403226-0500 rMove[541:62982] 6.10.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: [shortened URL here].
2019-12-02 16:28:27.420648-0500 rMove[541:62982] 6.10.0 - [Firebase/Analytics][I-ACS024000] Debug mode is on
2019-12-02 16:28:27.469885-0500 rMove[541:62982] 6.10.0 - [Firebase/Analytics][I-ACS005000] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at [shortened URL here]
2019-12-02 16:28:27.472623-0500 rMove[541:62982] 6.10.0 - [GoogleUtilities/AppDelegateSwizzler][I-SWZ001008] Successfully created App Delegate Proxy automatically. To disable the proxy, set the flag GoogleUtilitiesAppDelegateProxyEnabled to NO (Boolean) in the Info.plist
2019-12-02 16:28:27.474543-0500 rMove[541:62982] 6.10.0 - [Firebase/Messaging][I-FCM002000] FIRMessaging library version 4.1.9
2019-12-02 16:28:27.475493-0500 rMove[541:62982] 6.10.0 - [GULReachability][I-REA902003] Monitoring the network status
2019-12-02 16:28:27.476105-0500 rMove[541:62982] 6.10.0 - [GULReachability][I-REA902003] Monitoring the network status
2019-12-02 16:28:27.476841-0500 rMove[541:62982] 6.10.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
2019-12-02 16:28:27.479696-0500 rMove[541:62736] _PH_ called FirebaseApp.configure()
2019-12-02 16:28:27.481380-0500 rMove[541:62736] _PH_ set msg'ing delegate
2019-12-02 16:28:27.526128-0500 rMove[541:63008] 6.10.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60103000 started
2019-12-02 16:28:27.527311-0500 rMove[541:63008] 6.10.0 - [Firebase/Analytics][I-ACS023008] To disable debug logging set the following application argument: -noFIRAnalyticsDebugEnabled (see [shortened URL here])
2019-12-02 16:28:27.529499-0500 rMove[541:63008] 6.10.0 - [Firebase/Analytics][I-ACS023009] Debug logging enabled
2019-12-02 16:28:27.533081-0500 rMove[541:62736] _PH_ called registerForRemoteNotifications
这是我的应用程序的新版本,并且我尚未从工作版本中修改此代码。如何调试此问题?
答案 0 :(得分:0)
我使用Xcode的调试器发现,位于FirebaseApp.configure()调用堆栈中的Firebase Messaging试图在FirebaseApp.configure()设置默认的Firebase应用之前访问它。在* -Info.plist中设置FirebaseMessagingAutoInitEnabled的值可以解决此问题。在默认应用程序之前检查了plist值。