| 1 |
# tenjin |
| 2 |
|
| 3 |
This service integrates your iOS project with https://www.tenjin.com/[Tenjin], an install attribution service. |
| 4 |
|
| 5 |
See https://docs.tenjin.com/ 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 create an account on https://www.tenjin.com/ , add your game (for iOS), and get the API key from https://www.tenjin.io/dashboard/docs . |
| 8 |
|
| 9 |
## Declare in CastleEngineManifest.xml |
| 10 |
|
| 11 |
Declare it like this in link:https://castle-engine.io/project_manifest[CastleEngineManifest.xml]: |
| 12 |
|
| 13 |
[source,xml] |
| 14 |
---- |
| 15 |
<?xml version="1.0" encoding="utf-8"?> |
| 16 |
<project name="..." game_units="..."> |
| 17 |
<ios> |
| 18 |
<services> |
| 19 |
<service name="tenjin"> |
| 20 |
<parameter key="user_tracking_usage_description" value="Installation statistics help us improve the game" /> |
| 21 |
</service> |
| 22 |
</services> |
| 23 |
</ios> |
| 24 |
</project> |
| 25 |
---- |
| 26 |
|
| 27 |
The `user_tracking_usage_description` value is specified for Apple [NSUserTrackingUsageDescription](https://developer.apple.com/documentation/bundleresources/information_property_list/nsusertrackingusagedescription), it is shown to the user by the iOS, to explain why Tenjin needs to identify user for statistics. |
| 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 do this, 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');`. |