skip to Main Content

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


  1. 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.

        Firebase.Core.Options options = new Firebase.Core.Options("xxx", "xxx");
        options.ApiKey = "xxx";
        options.BundleId = "com.xxx.xxx";
        options.ProjectId = "xxx";
        options.ClientId = "xxx-xxx.apps.googleusercontent.com";
        options.StorageBucket = "xxx.appspot.com";
        options.DatabaseUrl = "https://xxx.firebaseio.com";
    
        events.AddiOS(iOS => iOS.WillFinishLaunching((_, __) =>
        {
            CrossFirebase.Initialize("myName", options);
            return false;
        }));
    
    Login or Signup to reply.
  2. 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.

    Firebase.Core.App.Configure("app-name", Firebase.Core.Options.DefaultInstance);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search