1. TnkAd SDK‎ > ‎

5) Unity Settings

You need tnkad.unitypackage file. [Download Unity plugin]

* At this time, Unity plugin supports Android only. iOS will be supported soon.

Open your Unity project and double click tnkad.unitypackage file. You can see Plugin import window like below. Check all items and click 'import' button to import plugin to your Unity project.


[Android Plugin Settings]

You may already have an AndroidMenifest.xml file in your project, If so, just copy and paste the information from the TnkAdAndroidManifest.xml file to the relevant sections of your won AndroidMenifest.xml file. 

Put your AndroidMenifest.xml file in /Assets/Plugins/Android folder.

Below is TnkAdAndroidMenifest.xml file. See the comments in the file and update your AndroidMenifest.xml file.

TnkAdAndroidMenifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="your.package.name" 
          android:theme="@android:style/Theme.NoTitleBar" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal">
  <uses-sdk android:minSdkVersion="9"/>
  
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  
  <!-- permissions for TnkAd -->
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  
  <application android:icon="@drawable/app_icon" android:label="@string/app_name">
    <activity android:label="@string/app_name" android:screenOrientation="portrait" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale" android:name="com.tnkfactory.spaceshootler.UnityPlayerNativeActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" /> <!-- set true -->
    </activity>
    
    <!-- TnkAd  Offerwall Activities -->
    <activity android:name="com.tnkfactory.ad.AdWallActivity" android:screenOrientation="portrait"/>
    <activity android:name="com.tnkfactory.ad.AdMediaActivity" android:screenOrientation="landscape"/>
    
    <!-- TnkAd Referrer tracking receiver -->
    <receiver android:name="com.tnkfactory.ad.TnkReceiver" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" /> 
        </intent-filter>
    </receiver>
    
    <!-- Set your Tnk App_ID here -->
    <meta-data android:name="tnkad_app_id" android:value="your-appid-from-tnk-site" />
        
  </application>
  
  <uses-feature android:glEsVersion="0x00020000" />
  <supports-gl-texture android:name="GL_OES_compressed_ETC1_RGB8_texture" />
  
</manifest>

 * Permissions

Set permissions that TnkAd SDK requires.

Permissions

  <!-- permissions for TnkAd -->
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

 * Tnk App Id

You can get App ID(Application Id) after adding your app in Tnk site. Put the App ID in <meta-data/> inside of <application/> tag at AndroidMenifest.xml file. In the sample below, replace your-application-id-from-tnk-site with your App ID value.
Be sure that <meta-data/> tag must reside inside of <application/> tag.

Tnk App Id

    <!-- Set your Tnk App_ID here -->
    <meta-data android:name="tnkad_app_id" android:value="your-appid-from-tnk-site" />

 * Offerwall Activity

For publishing app, add following 2 activities.

Offerwall Activity

    <!-- TnkAd  Offerwall Activities -->
    <activity android:name="com.tnkfactory.ad.AdWallActivity" android:screenOrientation="portrait"/>
    <activity android:name="com.tnkfactory.ad.AdMediaActivity" android:screenOrientation="landscape"/>

 * Referrer Receiver

To collect channel data for ananlytics, you have to add a <receiver/> tag for INSTALL_REFERRER.

Referrer Receiver

<!-- TnkAd Referrer tracking receiver -->
    <receiver android:name="com.tnkfactory.ad.TnkReceiver" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" /> 
        </intent-filter>
    </receiver>

 * UnityPlayer Settings

If you are using Unity 4.3 or above version, you must set ForwardNativeEventsToDalvik option to 'true' in order to Java receive touch events. For advertising app, you don't have to change this option.

UnityPlayer Option

<activity android:label="@string/app_name" android:screenOrientation="portrait" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale" android:name="com.tnkfactory.spaceshootler.UnityPlayerNativeActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" /> <!-- set true -->
    </activity>

Comments