Hi,
I am trying to implement Firebase Analytics in my Android project in Xamarin Forms...
My Dependency:
using System;
using Android.Content;
using Xamarin.Forms;
using Firebase.Analytics;
using Firebase.Crash;
using Android.OS;
[assembly: Dependency(typeof(ConvertAny.Droid.FirebaseService))]
namespace ConvertAny.Droid
{
public class FirebaseService : IFirebaseService
{
FirebaseAnalytics firebaseAnalytics;
public void Track_App_Page(String PageNameToTrack)
{
var bundle = new Bundle();
bundle.PutString(FirebaseAnalytics.Param.ItemId, "1");
bundle.PutString(FirebaseAnalytics.Param.ItemName, PageNameToTrack);
firebaseAnalytics.LogEvent(FirebaseAnalytics.Event.SelectContent, bundle);
}
}
}
In MainActivity:
FirebaseAnalytics firebaseAnalytics;
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
firebaseAnalytics = FirebaseAnalytics.GetInstance(this);
...........
...........
...........
In my Home.xaml.cs:
FirebaseDependencyService.Track_App_Page("Pages - Home");
But I am getting:
Object reference not set to an instance of an object.
On this line:
firebaseAnalytics.LogEvent(FirebaseAnalytics.Event.SelectContent, bundle);
Can anyone help please
Thanks,
Jassim