I’ve been working in a MAUI app and I have to use Firebase for analytics and Crashlytics. I used plugin.firebase package to implement that. In Android it is working fine, but in iOS while initializing Firebase package the app gets crash. Below code I’m using to initialize firebase.
private static MauiAppBuilder RegisterFirebaseServices(this MauiAppBuilder builder)
{
builder.ConfigureLifecycleEvents(events =>
{
#if IOS
events.AddiOS(iOS => iOS.WillFinishLaunching((app, launchOptions) => {
CrossFirebase.Initialize();
//Firebase.Core.App.Configure();
return false;
}));
#elif ANDROID
events.AddAndroid(android => android.OnCreate((activity, _) =>
{
CrossFirebase.Initialize(activity);
FirebaseAnalyticsImplementation.Initialize(activity);
}));
#endif
});
return builder;
}
I tried iOS 17.2 device and it is working fine. Only in iOS 17.4 I’m facing the crash issue. Other details like bundle id, GoogleService file are all correct.
2
Answers
I am facing the same issue. As a workaround I used the optional CrossFirebase.Initialize(name, firebaseOptions) constructor. Note that the values come from the GoogleService-Info.plist file.
Not ideal, but I needed something to move forward.
What worked for me was to pass in options using the DefaultInstance which populated everything from the plist for me. I’m using the direct firebase package (.Net for iOS), but you could do this within the CrossFirebase.Initialize() as well.