Forum Xamarin Xamarin.Forms

Not able to push custom events in Firebase Analytics

My environment:
Visual Studio 2017 version 15.8.9
Nuget Packages:
Xamarin.Firebase.iOS.Analytics - 5.1.4
Xamarin.Firebase.iOS.Core - 5.1.3
Xamarin.Firebase.iOS.InstanceID - 3.2.1

I have mentioned following mlaunch and start argument in iOS project properties -> iOS Run Optionts:

I am getting auto events like session_start, screen_view so my iOS App is sending events to Firebase.

I have implemented following solution for Firebase Analytics:
However I am facing issues in pushing custom events to Firebase for my iOS project. Android is pushing these custom events properly.

First problem:
following code throws an ambiguous error.(
if (parameters == null) { Analytics.LogEvent(eventId, null); return; }

So I tried following options:
option 1:
if (parameters == null) { Firebase.Analytics.Analytics.LogEvent(eventId, new Dictionary<object, object>(){{"key1", "value1"}}); return; }

Option 2:
`var keys = new List();
var values = new List();

        if (parameters == null)
            //Firebase.Analytics.Analytics.LogEvent(eventId, NSDictionary<NSString, NSObject>.FromObjectsAndKeys(values.ToArray(), keys.ToArray(), keys.Count));
            keys.Add(new NSString("Parameter"));
            values.Add(new NSString("NONE"));
            foreach (var item in parameters)
                keys.Add(new NSString(item.Key));
                values.Add(new NSString(item.Value));
      var parametersDictionary =
      NSDictionary<NSString, NSObject>.FromObjectsAndKeys(values.ToArray(), keys.ToArray(), keys.Count);
      Firebase.Analytics.Analytics.LogEvent(eventId, parametersDictionary);`

Both these options are not working. When I am checking debug log, I can find following

  • [I-ACS025018] Event not logged. Call +[FIRApp configure]: iOSAnalyticsStarted

I have attached whole log file. Can anyone please help?


Best Answers


  • NirajBhattNirajBhatt Member ✭✭

    @JassimRahma , were you able to push custom events of iOS to firebase analytics? any pointers? thanks.

  • Wojciech_KulikWojciech_Kulik USMember ✭✭
    edited December 2018

    It is exactly described what you have to do:

    Call +[FIRApp configure]: iOSAnalyticsStarted

    You did not initialized Firebase in AppDelegate.
    More details:

  • NirajBhattNirajBhatt Member ✭✭

    Hi @Wojciech_Kulik ,
    Thank you for reply and help. I am initializing Firebase in AppDelegate actually. That's how I am able to get auto events like session_start etc. But I am not getting custom events.

    AppDelegate FinishedLaunching event code:

             public override bool FinishedLaunching(UIApplication app, NSDictionary options)
            UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, false);
            this.hasNotificationPermissions = new Subject<bool>();
            this.latestNotification = new Subject<Tuple<string, string, string>>();
            Current = this;
            compositionRoot = new iOSCompositionRoot();
            new SplatRegistrar().Register(Locator.CurrentMutable, compositionRoot);
            // reset our badge
            UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
            // Code for starting up the Xamarin Test Cloud Agent


                 Xamarin.Calabash.Start ();


            AppSingleton.RegisterForRemoteNotifications.WhereNotNull().Do(unit =>
            UNUserNotificationCenter.Current.Delegate = new MyNotificationDelegate();
            Firebase.Analytics.Loader loader1 = new Firebase.Analytics.Loader();
            Firebase.InstanceID.Loader loader2 = new Firebase.InstanceID.Loader();
            return base.FinishedLaunching(app, options);
  • Wojciech_KulikWojciech_Kulik USMember ✭✭
    edited December 2018

    Did you follow all steps from:

    As you can see, there is a new parameter for debugging in this version "--argument=-FIRDebugEnabled"

  • NirajBhattNirajBhatt Member ✭✭

    Yes @Wojciech_Kulik . I have mentioned mlaunch argument also --argument=-FIRDebugEnabled.

    I am getting auto events but only custom events are not getting logged. I have attached log file.

    thanks again for helping out

  • NirajBhattNirajBhatt Member ✭✭

    Hi @Wojciech_Kulik ,

    Thank you for help. Yes I am going to try all these and will update here.

  • NirajBhattNirajBhatt Member ✭✭
    edited December 2018

    Hi @Wojciech_Kulik ,
    You were spot on. THe issue was that I was trying to log an event before Firebase Analytics was initialized.
    I have fixed that issue and now it's trying to log the custom event.
    However I am getting an error code type 2 ( firebase event error instead of my custom event which says event name is not correct.
    Any pointer on how to provide any custom event name when there are no parameters?
    My existing code:
    if (parameters == null)
    Firebase.Analytics.Analytics.LogEvent(eventId, new Dictionary<object, object>() { { "key1", "value1" } });

    Here eventId value is my custom string value.

  • NirajBhattNirajBhatt Member ✭✭

    Got it working after removing '-' in event name and it's working fine now. Thank you very much @Wojciech_Kulik for all the help.

Sign In or Register to comment.