Search This Blog

Thursday 26 May 2022

How to Integrate Firebase Crashlytics and Firebase Analytic In Your Xamarin Project

Firebase Crashlytics And Analytic Configuration For Android


Add Application in Google Firebase Console.
Create New Project in Google Firebase Console. Then Select Project Overview Option.

Click on +Add App Option & Select Android Project.

Add your Android Project Package Name here and then click on Register App.
Note: You will get the package name from the AndroidManifest.xml file.


Google-Service.json download this JSON file.
























Now Add this JSON file to your Android Project.















Now Right-click on the google-service.json file and Select Properties Option.















Select BuildAction : GoogleServiceJson
Copy to Output Directory: Do not copy.

Note: If you are not able to see GoogleServiceJson Build Action, Then Install the Following Plugin in your Android Project.
Xamarin.GooglePlayServices.Base
Xamarin.Google.Dagger

Xamarin.Anroid
Install the Following Plugin in your Xamarin Android Project.

Xamarin.Firebase.Analytics









Xamarin.Firebase.Crashlytics












Now Create a strings.xml file into the Resources/values folder of your Xamarin Android Project.

Add the following code in the strings.xml file
<?xml version="1.0" encoding="utf-8" ?>
<resources>
	<string name="com.google.firebase.crashlytics.mapping_file_id">none</string>
</resources>
 

Add this line in the OnCreate method of the MainActivity.cs file to send an unsent report of errors.
    Firebase.Crashlytics.FirebaseCrashlytics.Instance.SendUnsentReports();




All setup for android is done.


Firebase Crashlytics And Analytic Configuration For iOS

Create New Project in Google Firebase Console.
Then Select Project Overview Option.


Click on +Add App Option & Select iOS Project.





































Add your iOS Project Bundle Identifier here and then click on Register App.
You will get the Bundle Identifier from the Info.plist file.

Download GoogleService-Info.plist file and add this file to your Xamarin iOS Project.


Now Add this GoogleService-Info.plist file to your ios Project.



Select BuildAction: BundleResource
Copy to Output Directory: Do not copy.


Xamarin.iOS
Install the Following Plugin in your Xamarin iOS Project.

Xamarin.Firebase.iOS.Analytics










Xamarin.Firebase.iOS.Crashlytics











Now Initialize Firebase Services on AppDelegate.cs file

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
      global::Xamarin.Forms.Forms.Init();
      LoadApplication(new App());
 
      Firebase.Core.App.Configure();
      return base.FinishedLaunching(app, options);
}

All set up for iOS is done.

Now, You Can see Analytic Details & Crashes Detail on Firebase Console/Analytic, Firebase Console/Crashlytics Option.












No comments:

Post a Comment

Popular Posts