TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
211 stars 49 forks source link

Issue with crashlytics initialization #248

Closed Murtuzakabul closed 8 months ago

Murtuzakabul commented 8 months ago

I configured the plugin as per instructions. However I'm getting this error while trying to run my application

image

I made sure that the google-service.json file is there in my project along with respective info.plist file too.

Not able to understand what is causing the issue. Please let me know what further information is needed to fix this issue.

Here is the code of my mauiprogram.cs


    {
        public static MauiApp CreateMauiApp()
        {
            var builder = MauiApp.CreateBuilder();

            builder
                .UseMauiApp<App>()
                .UseMauiCommunityToolkit()
                .ConfigureFonts(fonts =>
                {
                    fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                    fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
                })
                 .ConfigureDeviceIdProvider()
                 .RegisterFirebaseServices();

            builder.Services.AddSingleton<DataService, DataService>(s =>
            {
                return new DataService(new JsonSerializerOptions()
                {
                    WriteIndented = true,
                    PropertyNamingPolicy = null,
                    PropertyNameCaseInsensitive = false,
                });
            });

#if DEBUG
            builder.Logging.AddDebug();
#endif

            return builder.Build();
        }

        private static MauiAppBuilder RegisterFirebaseServices(this MauiAppBuilder builder)
        {

            builder.ConfigureLifecycleEvents(events => {
#if IOS
                events.AddiOS(iOS => iOS.WillFinishLaunching((_, __) => {
                    CrossFirebase.Initialize();
                    return false;
                }));
#elif ANDROID
                events.AddAndroid(android => android.OnCreate((activity, _) => {
                }));

#endif
            });

            builder.Services.AddSingleton(_ => CrossFirebaseAuth.Current);
            return builder;
        }

    }
tranb3r commented 8 months ago

Most probably you forgot to set mapping_file_id? https://github.com/TobiasBuchholz/Plugin.Firebase/blob/development/docs/crashlytics.md#android-specifics

Murtuzakabul commented 8 months ago

Most probably you forgot to set mapping_file_id? https://github.com/TobiasBuchholz/Plugin.Firebase/blob/development/docs/crashlytics.md#android-specifics

I've added it. Attaching here a screenshot of the same so as to ensure that it has been added correctly..

image

tranb3r commented 8 months ago

The folder should be Platforms/Android/Resources/values

Murtuzakabul commented 8 months ago

The folder should be Platforms/Android/Resources/values

I'm trying the same and will let you know.

Murtuzakabul commented 8 months ago

Worked!!. Can you please guide me on what documentation should I follow to enable push notification. Thanks a lot.

tranb3r commented 8 months ago

For push notification, here is the link to the documentation: https://github.com/TobiasBuchholz/Plugin.Firebase/blob/development/docs/cloud_messaging.md You should probably also have a look at the sample's code.