Unity Plugin Integration

Before You Start

  • We support Unity version 4.6.8 and up.
  • We support Android Operating Systems Version 4.1 (API level 16) and up.
  • We support XCode 9.0 and up as well as CocoaPods.
  • We suggest creating an AdTiming account and registering an Android and/or iOS app.

Note: The download, use and access to the SDK is subject to the AdTiming Mobile SDK Publisher Online Terms & Conditions. If you do not agree to the terms of AdTiming Mobile SDK Publisher Online Terms & Conditions, do not download, access, or use the SDK, or the underlying services.

Overview

This Guideline is intended for publishers who need to monetize for an Unity app.

AdTiming offers diversified and competent monetization services and supports a variety of Ad formats including Native Ad, Interstitial Ad, Banner Ad, and Incentive Video Ad. The AdTiming platform mediates AdTiming, AdMob, Facebook, UnityAds, Vungle, Tapjoy, AppLovin, AdColony, Chartboost, Pangle, MoPub and IronSource.

Interested in Mediation? Integrate our Rewarded Video, Interstitial Ads in your app and follow our Add Mediation Networks and Mediation Integration Guides.

 

Step 1. Add the AdTiming Unity Package to Your Project

Disclaimer: Updating the AdTiming SDK

When upgrading from older SDK versions to the AdTiming SDK 6.0.0 and above, you must download and update all mediation adapters.

Follow these steps to add the AdTiming Unity Package to your project:

  1. Download AdTiming Unity Plugin
  2. Make sure your Unity project is opened in the Unity editor
  • The AdTiming SDK is designed to work with the Android & iOS platform. The Unity Editor contains a Simulator to work with Unity code. In order to work with our plugin, you must target either an Android or iOS build to test the integration.
  1. Import the Unity package.
  • Navigate to Assets -> Import Package -> Custom Package.

WechatIMG23.png

  • Select the AdTimingUnityPlugin(Vx.x.x).unitypackage file..
  • Import all files and make sure to avoid conflicts with files. (Double-click on the extracted file; the different files will be populated automatically as shown below).

WechatIMG24.png

 

Step 2. Add the SDK to Your Project

Android

AdTiming Supports both Gradle dependenceies and menual download mechanisms to integrate our SDK. See Android SDK Integration for more infomation.

iOS

AdTiming supports both Cocoapods and manual download for SDK integration. See iOS SDK Integration for more infomation.

Note: when Unity engine version number is higher than 2019.3.14f1, please use target 'UnityFramework' do to execute Cocoapods command.

 

Step 3. Initialize the Ad Units

Before loading ads, initialize the AdTiming SDK by calling AdTiming.Agent.Init(“appKey”, initListener) with your AppKey. This is best done at the time of the app launch, and only needs to be done once. Here’s an example of how to call Init() within the Start() method of a script attached to a GameObject. At the same time, the interface AdtInitListener must be implemented to receive events of the init() call and handle it accordingly.

public void Start()
{
    AdTiming.Agent.init("Your AdTimingAppKey", new AdTimingInitListener());
}
class AdTimingInitListener : AdtInitListener
{
    public void onError(string message)    
    {        
        Debug.LogError(message);
    }
    public void onSuccess() 
    {
        Debug.Log("Init onSuccess");
    }
}

 

isInitialized

After calling the init() method, you can also use the following code to determine whether the SDK has been successfully initialized.

// To determine the result of init()
AdTiming.Agent.isInitialized()

  

Set IAP Parameter(optional)

IAP, an acronym for in-App Purchase, can be understood as an in-app purchase. We need you to pass the current device user's IAP data to the SDK through the setIap method in the APP so that we can provide more accurate advertising.

AdTiming.Agent.setIap(float count, String currency); 

The parameter currency is a String represents the currency code of the ISO, based on the International Organization for Standardization's national code, is published in the ISO 4217:2008 standard and is used to represent money and funds.

You could set IAP after SDK initial successfully, such as at the time the IAP data is changed.

…
AdTiming.Agent.setIap(12.30, 'USD');
… 

 

Send attribution data to AdTiming(optional)

If your project also integrates the AppsFlyer SDK, we need you to pass the application attribution data to AdTiming so that we can help you accurately calculate each Media Source, Campaign level ROAS, and LTV data.

1. When you receive the onConversionDataSuccess callback you can use the sendAFConversionData method for passing the attribution data dictionary:

public void onConversionDataSuccess(string conversionData) {
    AdTiming.Agent.sendAFConversionData(conversionData);
}

2. When you receive the onAppOpenAttribution callback you can use the sendAFDeepLinkData method for passing the attribution data dictionary:

public void onAppOpenAttribution(string validateResult) {
    AdTiming.Agent.sendAFDeepLinkData(validateResult);
}

 

Step 4. Add Mediation Networks

Interested in Mediation? Integrate our Rewarded Video, Interstitial Ads in your app and follow our Add Mediation Networks and Mediation Integration Guides to mediate networks.

Attention! The adapter for each ad network is modularized, so you need to download and add Not Only the SDK of mediation networks you choose to work with But Also the adapters for those ad networks.

For example, if you want to integrate AdMob and Applovin through AdTiming Mediation, you need to add the AdMob Adapter, AdMob SDK and Applovin Adapter, AppLovin SDK to the libs of your project. See the Add Mediation Networks for more infomation.

Was this article helpful?
3 out of 3 found this helpful

Comments

0 comments

Article is closed for comments.