Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/f-miyu/plugin.firebaseanalytics
https://github.com/f-miyu/plugin.firebaseanalytics
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/f-miyu/plugin.firebaseanalytics
- Owner: f-miyu
- License: mit
- Created: 2018-11-09T11:34:51.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-02T04:14:59.000Z (about 4 years ago)
- Last Synced: 2024-11-29T00:22:22.865Z (about 2 months ago)
- Language: C#
- Size: 561 KB
- Stars: 18
- Watchers: 2
- Forks: 11
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Plugin.FirebaseAnalytics
A cross platform plugin for Firebase Analytics.
A wrapper for [Xamarin.Firebase.iOS.Analytics](https://www.nuget.org/packages/Xamarin.Firebase.iOS.Analytics/)
and [Xamarin.Firebase.Analytics](https://www.nuget.org/packages/Xamarin.Firebase.Analytics).## Setup
Install Nuget package to each projects.[Plugin.FirebaseAnalytics](https://www.nuget.org/packages/Plugin.FirebaseAnalytics/) [![NuGet](https://img.shields.io/nuget/vpre/Plugin.FirebaseAnalytics.svg?label=NuGet)](https://www.nuget.org/packages/Plugin.FirebaseAnalytics/)
### iOS
* Add GoogleService-Info.plist to iOS project. Select BundleResource as build action.
* Initialize as follows in AppDelegate.
```C#
Firebase.Core.App.Configure();
```### Android
* Add google-services.json to Android project. Select GoogleServicesJson as build action. (If you can't select GoogleServicesJson, reload this android project.)
* Target framework version needs to be Android 10.0.
* This Plugin uses [Plugin.CurrentActivity](https://github.com/jamesmontemagno/CurrentActivityPlugin). Setup as follows in MainActivity.
```C#
Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, bundle);
```## Usage
### Log events
```C#
CrossFirebaseAnalytics.Current.LogEvent(EventName.SelectContent,
new Parameter(ParameterName.ItemId, itemId),
new Parameter(ParameterName.ItemName, itemName));var parameters = new Dictionary
{
[ParameterName.ItemId] = 1,
[ParameterName.ItemName] = "test"
};
CrossFirebaseAnalytics.Current.LogEvent(EventName.SelectContent, parameters);
```### Set user properties
```C#
CrossFirebaseAnalytics.Current.SetUserProperty("name", userName);
```### Set user id
```C#
CrossFirebaseAnalytics.Current.SetUserId(userId);
```### Set screen name
```C#
CrossFirebaseAnalytics.Current.SetCurrentScreen(screenName, screenClass));
```### Get app instance id
```C#
var id = await CrossFirebaseAnalytics.Current.GetAppInstanceIdAsync();
```### Reset analytics data
```C#
CrossFirebaseAnalytics.Current.ResetAnalyticsData();
```### Set parameters
```C#
CrossFirebaseAnalytics.Current.SetAnalyticsCollectionEnabled(enabled);CrossFirebaseAnalytics.Current.SetSessionTimeoutDuration(sessionTimeoutDuration);
```