使用选项配置 firebase 在 Xcode 11 和 Firebase 6.19 中崩溃
configure firebase with options is crashing in Xcode 11 and Firebase 6.19
我正在尝试在我的应用程序中注册第二个 firebase 应用程序。第一个在 didFinishWithLaunchingWithOptions
方法中正确注册(默认使用 GoogleService-Info.plist)
FirebaseApp.configure()
然后我需要从服务器检索一个新的 googleAppId,并使用这个新的 googleAppId 和我的 curse iOSID 配置一个新的应用程序。我正在 AppDelegate 中进行所有这些注册。我是这样注册的:
let options = FirebaseOptions(googleAppID: String(format: "1:%a:ios:%a", googleID, iOSID), gcmSenderID: googleID)
//Deleting the first app in order to register the second
let app = FirebaseApp.app()
app?.delete { _ in }
FirebaseApp.configure(options: options)
在我将我的 firebase 版本从 6.2 更新到 6.19 之前它运行良好,现在应用程序在 FirebaseApp.configure(options: options)
中崩溃
日志说:
Terminating app due to uncaught exception 'com.firebase.installations', reason
'[Firebase/Installations][I-FIS008000] Could not confiure Firebase Installations die to invalid
Firebase options. The following parameters are nil or empty: `FirebaseOptions.APIKEY`. If you
use GoogleServices-Info.plist please download the most recent version from the Firebase Console.
If you configure Firebase in code, please make sure you specify all required paramaters.
值得一提的是,在 Firebase 版本 6.15 中向 Analytics 添加了一个新框架,因此我必须添加它才能再次编译我的应用程序。
我也尝试在 FirebaseOptions
中添加一个新参数,但仍然要求相同的参数,它不期望 APIKEY,我不知道从哪里得到它
据我所知,该消息来自 here。在那里进行的检查表明必须始终指定这三个值:
if (appName.length < 1) {
[missingFields addObject:@"`FirebaseApp.name`"];
}
if (appOptions.APIKey.length < 1) {
[missingFields addObject:@"`FirebaseOptions.APIKey`"];
}
if (appOptions.googleAppID.length < 1) {
[missingFields addObject:@"`FirebaseOptions.googleAppID`"];
}
根据错误消息和您的代码,您似乎没有在 FirebaseOptions 中指定 APIKEY
,这是 SDK 所要求的。
我正在尝试在我的应用程序中注册第二个 firebase 应用程序。第一个在 didFinishWithLaunchingWithOptions
方法中正确注册(默认使用 GoogleService-Info.plist)
FirebaseApp.configure()
然后我需要从服务器检索一个新的 googleAppId,并使用这个新的 googleAppId 和我的 curse iOSID 配置一个新的应用程序。我正在 AppDelegate 中进行所有这些注册。我是这样注册的:
let options = FirebaseOptions(googleAppID: String(format: "1:%a:ios:%a", googleID, iOSID), gcmSenderID: googleID)
//Deleting the first app in order to register the second
let app = FirebaseApp.app()
app?.delete { _ in }
FirebaseApp.configure(options: options)
在我将我的 firebase 版本从 6.2 更新到 6.19 之前它运行良好,现在应用程序在 FirebaseApp.configure(options: options)
日志说:
Terminating app due to uncaught exception 'com.firebase.installations', reason
'[Firebase/Installations][I-FIS008000] Could not confiure Firebase Installations die to invalid
Firebase options. The following parameters are nil or empty: `FirebaseOptions.APIKEY`. If you
use GoogleServices-Info.plist please download the most recent version from the Firebase Console.
If you configure Firebase in code, please make sure you specify all required paramaters.
值得一提的是,在 Firebase 版本 6.15 中向 Analytics 添加了一个新框架,因此我必须添加它才能再次编译我的应用程序。
我也尝试在 FirebaseOptions
中添加一个新参数,但仍然要求相同的参数,它不期望 APIKEY,我不知道从哪里得到它
据我所知,该消息来自 here。在那里进行的检查表明必须始终指定这三个值:
if (appName.length < 1) { [missingFields addObject:@"`FirebaseApp.name`"]; } if (appOptions.APIKey.length < 1) { [missingFields addObject:@"`FirebaseOptions.APIKey`"]; } if (appOptions.googleAppID.length < 1) { [missingFields addObject:@"`FirebaseOptions.googleAppID`"]; }
根据错误消息和您的代码,您似乎没有在 FirebaseOptions 中指定 APIKEY
,这是 SDK 所要求的。