Created
May 14, 2019 04:09
-
-
Save kakobotasso/f42f6db384850d9251c2259fdc237417 to your computer and use it in GitHub Desktop.
IEventTracker implementation FireEvents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using Android.OS; | |
using Firebase.Analytics; | |
using FireEvents; | |
using FireEvents.Droid; | |
using Xamarin.Forms; | |
[assembly: Dependency(typeof(EventTrackerDroid))] | |
namespace FireEvents.Droid | |
{ | |
public class EventTrackerDroid : IEventTracker | |
{ | |
public void SendEvent(string eventId) | |
{ | |
SendEvent(eventId, null); | |
} | |
public void SendEvent(string eventId, string paramName, string value) | |
{ | |
SendEvent(eventId, new Dictionary<string, string> | |
{ | |
{paramName, value} | |
}); | |
} | |
public void SendEvent(string eventId, IDictionary<string, string> parameters) | |
{ | |
var firebaseAnalytics = FirebaseAnalytics.GetInstance(Forms.Context); | |
if(parameters == null) | |
{ | |
firebaseAnalytics.LogEvent(eventId, null); | |
return; | |
} | |
var bundle = new Bundle(); | |
foreach(var param in parameters) | |
{ | |
bundle.PutString(param.Key, param.Value); | |
} | |
firebaseAnalytics.LogEvent(eventId, bundle); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment