Search code examples
xamarinxamarin.formsfirebase-analytics

How to integrate Xamarin.Firebase.Analytics to the Xamarin.forms?


Problem: But I don't see an active user in my firebase account.

I do this.

  1. I add package the Xamarin.Firebase.Analytics to the MyName.Android project.

  2. I add the google-services.json in My Name.Android.

  3. Install build Action = GoogleService.json

  4. I run the project as "Debug".

description of the problem: The project is successfully assembled and running, but the standard actions in the firebase statistics are not fixed: first_open, screen_view, session_start.

description of the problem: The firebase statistics in the realtime section are also empty.

Please tell me what I'm doing wrong? Do I need additional packages? "Xamarin.Firebase.Analytics" need to be initialized in MainActivity?

Developers create nuget packages and upload them to github. Some developers write instructions. And some do not write instructions. The question is where to look for instructions?


Solution

  • Add to MainAvtivity.cs (for Android)

    1. using Firebase.Analytics;
    2. FirebaseAnalytics firebaseAnalytics; to the beginning of class MainActivity
    3. to the method onCreate firebaseAnalytics = FirebaseAnalytics.GetInstance(this);
    4. in the properties of the google-service.json file, set build action = Google Services.Json
    5. look at my package versions. This link is working. I'm tired of picking up packages...

    look at my package versions. This link is working. I'm tired of picking up packages...

    Add to AppDelegate.cs (for iOS)

    1. before namespace add the following − [assembly: Preserve(typeof(Firebase.Analytics.Analytics), AllMembers = true)]
    2. before return base.FinishedLaunching(app, options); add the code Firebase.Core.App.Configure();
    3. i use Xamarin.Firebase.iOS.Anatics(6.9.0)

    The rest is according to the instructions in firebase for ios