Step-by-step Tenjin SDK integration on any platform or framework

Diego Giraldo
Tenjin Engineering
Published in
4 min readMar 30, 2023

Tenjin brings transparency and insight into mobile marketing. In addition to supporting hundreds of ad networks and being an MMP, Tenjin provides powerful tools and training for any marketer to analyze the source, in-app purchases, advertising revenue, cost, and users’ ROI.

Tenjin Mobile SDKs allows users to track events and installs in their mobile apps. To learn more about Tenjin, you can visit its website.

On this article I’m going to show you how you can integrate Tenjin’s SDK into any mobile app on any platform/framework. I’ll cover iOS, Android, Unity, React Native and Ionic, although Tenjin is providing support for more frameworks in the near future.

iOS

Let’s start with iOS. To get the SDK you can use Cocoapods or Swift Package Manager.

Cocoapods

If you use pods, add pod 'TenjinSDK' to your Podfile then run pod install.

Swift Package Manager

If you use SPM, add Tenjin’s SDK package through Xcode with this repository here.

  • For AppTrackingTransparency, update your project .plist file and add Privacy - Tracking Usage Description (NSUserTrackingUsageDescription) along with the text message you want to display to users.
  • Include the linker flag -ObjC under your Build Settings, you can find it as “Other Linker Flags”
  • Import and initialize Tenjin on your source code, we recommend requesting ATT before doing the connect call:

Objective-C

#import "TenjinSDK.h"

@implementation TJNAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[TenjinSDK initialize:@"<SDK_KEY>"];
[TenjinSDK requestTrackingAuthorizationWithCompletionHandler:^(NSUInteger status) {
[TenjinSDK connect];
}];

//All your other stuff
...
}

Swift

You need to import the SDK on your Objective-C bridging header

#import "TenjinSDK.h"

Then, you can just use it on your Swift source code:

TenjinSDK.getInstance("<SDK_KEY>")
TenjinSDK..requestTrackingAuthorization { _ in
TenjinSDK.connect()
}

Android

To get Android’s SDK you can use Maven, to import it you need to add its library to your Gradle dependencies:

  • Add implementation com.tenjin:android-sdk:VERSION to your Gradledependencies and add mavenCentral() to the source repositories if it’s not there already.
  • Add the following permissions to your apps manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
  • Add the following dependencies on your Gradle file:
dependencies {
implementation 'com.google.android.gms:play-services-ads-identifier:{version}'
implementation 'com.android.installreferrer:installreferrer:{version}'
}
  • Import the SDK on your source code:
import com.tenjin.android.TenjinSDK;
  • Initialize and call the connect method on your activity onResume():
TenjinSDK instance = TenjinSDK.getInstance(this, "<SDK_KEY>");

instance.connect();

Unity

If you use Unity, you can follow these steps to integrate the SDK:

  • Download the latest Unity SDK from here.
  • Import the TenjinUnityPackage.unitypackage into your project: Assets -> Import Package
  • By default, Tenjin includes Google Play Services AAR files as part of the SDK. If you do not plan on using Google Play Services, you can delete these AAR files:/Assets/Plugins/Android/play-services-*.aar
    /Assets/Plugins/Android/installreferrer-*.aar
  • Initialize and call the connect method:
BaseTenjin instance = Tenjin.getInstance("<SDK_KEY>");

instance.Connect();

iOS Specific Configuration

  • On the iOS generated project, update your project .plist file and add Privacy - Tracking Usage Description (NSUserTrackingUsageDescription) along with the text message you want to display to users.

Android Specific Configuration

  • Add these to your Proguard settings on the Android generated project:
-keep class com.tenjin.** { *; }
-keep public class com.google.android.gms.ads.identifier.** { *; }
-keep public class com.google.android.gms.common.** { *; }
-keep public class com.android.installreferrer.** { *; }
-keep class * extends java.util.ListResourceBundle {
protected java.lang.Object[][] getContents();
}
-keepattributes *Annotation*

React Native

If you use React Native, follow these steps to integrate the SDK:

  • Import the library into you project: npm install react-native-tenjin
  • Import Tenjin on your source code:
import Tenjin from 'react-native-tenjin';
  • Initialize and call the connect method:
Tenjin.initialize(apiKey)
Tenjin.connect()

iOS Specific Configuration

On the iOS generated project, update your project .plist file and add Privacy - Tracking Usage Description (NSUserTrackingUsageDescription) along with the text message you want to display to users.

Android Specific Configuration

You will need to add Google’s Install Referrer Library to your gradle dependencies. If you haven’t already installed the Google Play Services you also need to add it:

dependencies {
classpath("com.android.installreferrer:installreferrer:1.1.2")
classpath("com.google.android.gms:play-services-analytics:17.0.0")
}

Ionic

If you use Ionic, follow these steps to integrate the SDK:

  • Import the library into you project:
npm install ionic-capacitor-tenjin
npx cap sync
  • Import Tenjin on your source code:
import Tenjin from 'ionic-capacitor-tenjin';
  • Initialize and call the connect method:
Tenjin.initialize(sdkKey: string)
Tenjin.connect()

iOS Specific Configuration

On the iOS generated project, update your project .plist file and add Privacy - Tracking Usage Description (NSUserTrackingUsageDescription) along with the text message you want to display to users.

Android Specific Configuration

You will need to add Google’s Install Referrer Library to your gradle dependencies. If you haven’t already installed the Google Play Services you also need to add it:

dependencies {
classpath("com.android.installreferrer:installreferrer:1.1.2")
classpath("com.google.android.gms:play-services-analytics:17.0.0")
}

Done! After this, you are ready to go and can use any Tenjin method on any platform.

If you need more information about the methods available to use from Tenjin’s SDK, follow their development documentation here.

--

--