- Download the lastest release of the Xamarin Android SDK
- Unzip / untar the downloaded SDK into a preferred directory
- In Xamarin, right click on Master Solution -> Add -> Add Existing Project
- In the opened dialog window, locate the unzipped Xamarin Android SDK directory and click Finish
- In Xamarin, right click on master project References -> Edit References...
- In the opened dialog find InfinarioAndroidSDK, check it and then OK
- In Manifest.xml add these permissions
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
- In Manifest.xml add into application tag these receivers
<receiver android:name="com.infinario.android.infinariosdk.AlarmReceiver" android:exported="true" > </receiver>
<receiver android:name="com.infinario.android.infinariosdk.BootReceiver" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> <receiver android:name="com.infinario.android.infinariosdk.ConnectivityReceiver" android:enabled="false" > <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> </intent-filter> </receiver> <receiver android:name="com.infinario.android.infinariosdk.ReferrerReceiver" android:exported="true" > <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver></code></pre></li>
After completing the steps above the Infinario Xamarin Android SDK is now included in your project and ready to be used.
using Com.Infinario.Android.Infinariosdk; //for IDictionary using System.Collections.Generic;
Once the IDE is set up, you may start using the Infinario library in your code. First you need to you need to know the URI of your Infinario API instance, usualyhttps://api.infinario.com
and yourcompanyToken
(located at the Company / Overview page in the web application). To interact with the Infinario SDK, you need to obtain an instance of the Infinario class using theapplication's context
andcompanyToken
(the URI parameter is optional):
To start tracking, you need to identify the customer with their unique// Use public Infinario instance Infinario infinario = Infinario.GetInstance(this.ApplicationContext, companyToken);
// Use custom Infinario instance Infinario infinario = Infinario.GetInstance(this.ApplicationContext, companyToken, "http://url.to.your.instance.com");
customerId
. The uniquecustomerId
can either be a String, or an Map representing thecustomerIds
as referenced in the API guide. SettingString customerId = "123-foo-bar"
is equivalent to
IDictionary<string, Java.Lang.Object> customerId = new Dictionary<string,Java.Lang.Object>(); customerId.Add("registered", "123-foo-bar");
In order to identify a customer, call the
identify()
method on the obtained Infinario instance as follows:// Identify a customer with their customerId infinario.Identify(customerId);
The identification is performed asynchronously and there is no need to wait for it to finish. All tracked events are stored in the internal SQL database until they are sent to the Infinario API.
You may track any event by calling the
track()
method on the Infinario instance. Thetrack()
method takes one mandatory and two optional arguments. First argument isString type
which categorizes your event. This argument is required. You may choose any string you like.Next two arguments are
IDictionary<string, Java.Lang.Object> properties
andLong timestamp
. Properties is a map which usesString
keys and the value may be anyObject
which is serializable byorg.json.JSONObject
class. Properties can be used to attach any additional data to the event. Timestamp is standard UNIX timestamp in seconds and it can be used to mark the time of the event's occurence. The default timestamp is preset to the time of the tracking of the event.IDictionary<string, Java.Lang.Object> properties = new Dictionary<string,Java.Lang.Object>(); properties.Add("item_id", 45); Long timestamp = Java.Lang.JavaSystem.CurrentTimeMillis * 1000L; // Tracking of buying an item with item's properties at a specific time Track("item_bought", properties, timestamp); // Tracking of buying an item at a specific time Track("item_bought", timestamp); // Tracking of buying an item with item's properties Track("item_bought", properties); // Basic tracking that an item has been bought Track("item_bought");
The Infinario Android SDK provides you with means to store arbitrary data that is not event-specific (e.g. customer's age, gender, initial referrer). Such data is tied directly to the customer as their properties. The
update()
method is used to store such data:IDictionary<string, Java.Lang.Object> properties = new Dictionary<string,Java.Lang.Object>(); properties.Add("age", 34); // Store customer's age infinario.Update(properties);
INFINARIO Android SDK automatically tracks some events on its own. Automatic events ensure that basic user data gets tracked with as little effort as just including the SDK into your game. Automatic events include sessions, installation, identification and payments tracking.
Session is a time spent in the game, it starts when the game is launched and ends when the game gets dismissed from recent apps or is freed from memory in another way. Automatic tracking of sessions produces two events,
session_start
andsession_end
. Both events contain the timestamp of the occurence together with basic attributes about the device (OS, OS version, SDK, SDK version and device model). Eventsession_end
contains also the duration of the session in seconds. Example ofsession_end
event attributes in JSON format:{ "duration": 125, "device_model": "LGE Nexus 5", "ip": "10.0.1.58", "os_name": "Android", "os_version": "5.0.1", "sdk": "AndroidSDK", "sdk_version": "1.0.4" }
Installation event is fired only once for the whole lifetime of the game on one device when the game is launched for the first time. Besides the basic information about the device (OS, OS version, SDK, SDK version and device model), it also contains additional attribute called campaign_id which identifies the source of the installation. For more information about this topic, please refer to the aquisition documentation. Please note that
com.android.vending.INSTALL_REFERRER
intent is used to acquire the source of the installation. Example of installation event:{ "campaign": "Advertisement on my website", "campaign_id": "ui9fj4i93jf9083094fj9043", "link": "https://play.google.com/store/...", "device_model": "LGE Nexus 5", "ip": "10.0.1.58", "os_name": "Android", "os_version": "5.0.1", "sdk": "AndroidSDK", "sdk_version": "1.0.4" }
Identification event is tracked each time the
identify()
method is called. It contains all basic information regarding the device (OS, OS version, SDK, SDK version and device model) as well as registered attribute which identifies the player. Example of an identification event:All tracked events are stored in the internal SQL database in the Android app. By default, Infinario Android SDK automagically takes care of flushing events to the Infinario API. This feature can be turned off with method{ "registered": "[email protected]", "device_model": "LGE Nexus 5", "ip": "10.0.1.58", "os_name": "Android", "os_version": "5.0.1", "sdk": "AndroidSDK", "sdk_version": "1.0.4" }
disableAutomaticFlushing()
which takes no arguments. Please be careful with turning automatic flushing off because if you turn it off, you need to manually callInfinario.flush(context);
to flush the tracked events manually everytime there is something to flush.
-
Notifications
You must be signed in to change notification settings - Fork 0
Infinario/xamarin-android-sdk
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|