| 1 |
## tenjin |
| 2 |
|
| 3 |
This service integrates your Android project with https://www.tenjin.com/[Tenjin], an install attribution service. |
| 4 |
|
| 5 |
See https://docs.tenjin.com/[Tenjin docs] for an overview of what Tenjin offers. It is a commercial service, although can be used for free with some limits. |
| 6 |
|
| 7 |
You will need to: |
| 8 |
|
| 9 |
- Create an account on https://www.tenjin.com/[Tenjin], add your game (for Android), and get the API key from https://www.tenjin.io/dashboard/[Tenjin dashboard] (this step is similar as for iOS). |
| 10 |
|
| 11 |
- You also need to allow Tenjin to verify purchases done on Google Play. See https://github.com/tenjin/tenjin-android-sdk#purchase-events[Tenjin Android docs], section _"Purchase Events"_. |
| 12 |
|
| 13 |
### Declare in CastleEngineManifest.xml |
| 14 |
|
| 15 |
Declare it like this in link:https://castle-engine.io/project_manifest[CastleEngineManifest.xml]: |
| 16 |
|
| 17 |
[source,xml] |
| 18 |
---- |
| 19 |
<?xml version="1.0" encoding="utf-8"?> |
| 20 |
<project name="..." game_units="..."> |
| 21 |
<android> |
| 22 |
<services> |
| 23 |
<service name="tenjin" /> |
| 24 |
</services> |
| 25 |
</android> |
| 26 |
</project> |
| 27 |
---- |
| 28 |
|
| 29 |
### Use from Pascal |
| 30 |
|
| 31 |
*(Note that working with Tenjin on Android and iOS is the same from Pascal, so you can use a single code to handle both.)* |
| 32 |
|
| 33 |
Create a single instance of `TCastleTenjin` class (from `CastleTenjin` unit). You can do this e.g. in the `Application.OnInitialize` callback. You can use the fact that `TCastleTenjin` descends from `TComponent`, and set the owner of it to be `Application`, to make it freed automatically. |
| 34 |
|
| 35 |
Then initialize the analytics reporting. Make sure to ask users for permission to collect data, in particular in EU where GDPR is in effect. Make sure to mention this in your application's privacy policy too. |
| 36 |
|
| 37 |
Like this: |
| 38 |
|
| 39 |
[source,pascal] |
| 40 |
---- |
| 41 |
var |
| 42 |
MyTenjin: TCastleTenjin; |
| 43 |
|
| 44 |
procedure ApplicationInitialize; |
| 45 |
begin |
| 46 |
... |
| 47 |
|
| 48 |
MyTenjin := TCastleTenjin.Create(Application); |
| 49 |
MyTenjin.Initialize('YOUR-TENJIN-API-KEY'); |
| 50 |
end; |
| 51 |
---- |
| 52 |
|
| 53 |
Optionally you can also send custom events to Tenjin. Just call from anywhere `MyTenjin.SendEvent('event_name');`. |
| 54 |
|
| 55 |
### Using Android Advertising ID (AAID) |
| 56 |
|
| 57 |
The _Tenjin_ service does use _Android Advertising ID (AAID)_. |
| 58 |
|
| 59 |
We declare the `com.google.android.gms.permission.AD_ID` permission in the application. |
| 60 |
|
| 61 |
On _Google Play_, in the corresponding survey, you have to answer _Yes_ when asked whether the app uses _Android Advertising ID (AAID)_. |