Prerequisites

Setup

Sample Code

You can optionally download sample code: Download

Import Unity Packages

  • Remove Assets/AMR and Plugins/Android/amr_definition folders if present.
  • Select necessary network adapters and download package.
  • Import package to your Unity project.

Please refer to following table for required and optional packages for your target.

Status Name Download Links
Required Unity Core
Optional AdColony
Optional AdMob
Optional Admost
Optional Adtiming
Optional Amazon
Optional AppLovin
Optional Appnext
Optional Appsamurai
Optional Chartboost
Optional Criteo
Optional DFP
Optional Facebook
Optional Fyber
Optional InMobi
Optional Inneractive
Optional IronSource
Optional Mintegral
Optional Mobfox
Optional Mopub
Optional MyTarget
Optional Nexage
Optional Qumpara
Optional Pollfish
Optional Smaato
Optional StartApp
Optional Tapjoy
Optional TapResearch
Optional TikTok
Optional Unity Ads
Optional Vungle
Optional YandexAds
Optional YouAppi

Android Setup Notes

Gradle Custom Template is strongly recommended to prevent library conflicts. (In Unity Editor: Player Settings > Publishing Settings > check Custom Gradle Template).

Android Resolver sould be run. (In Unity Editor: Assets > Play Services Resolver > Android Resolver > click Resolve or Force Resolve.



NOTE: Recommended Gradle Build Tools Plugin version is 3.2.0 (e.g: in mainTemplate.gradle file, check the line of classpath 'com.android.tools.build:gradle:3.2.0'). Other versions of 3.x.x and upwards could also be used. Usage of 2.x.x is valid but not tested well.

If you face with gradle related build errors, please check it: Gradle Build Tools Plugin version and Gradle version should be compatible version mapping

NOTE 2: You may need to add google() repository to the repositories { } tag in mainTemplate.gradle file if not present.


  • AppLovin Configuration
  • Mopub Configuration
  • AdMob Configuration for Play Services Ads 17.0.0 or higher

iOS Setup Notes

Xcode Setup

Add following lines to your plist file.

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>
<key>NSCalendarsUsageDescription</key>
<string>Some ad content may access calendar</string>
Version Warning
AppLovin, Facebook, Loopme, Mobfox, Pollfish and YouAppi adapters support iOS9 or later.

Usage

Initialization

To initialize Admost Mediation SDK, create and configure instance of an AMRSdkConfig and start the SDK with your config object.


void Start()
{
    AMR.AMRSdkConfig config = new AMR.AMRSdkConfig();
    config.ApplicationIdAndroid = "<Your Android App Id>";
    config.ApplicationIdIOS = "<Your IOS App Id>";

    config.BannerIdAndroid = "<Your Android Banner Zone Id>";
    config.BannerIdIOS = "<Your IOS Banner Zone Id>";

    config.InterstitialIdAndroid = "<Your Android Interstitial Zone Id>";
    config.InterstitialIdIOS = "<Your IOS Interstitial Zone Id>";

    config.RewardedVideoIdAndroid = "<Your Android Video Zone Id>";
    config.RewardedVideoIdIOS = "<Your IOS Video Zone Id>";

    config.OfferWallIdAndroid = "<Your Android Offerwall Zone Id>";
    config.OfferWallIdIOS = "<Your IOS Offerwall Zone Id>";

    AMR.AMRSDK.startWithConfig(config);
}
                

GDPR

Once you have collected the user’s consent, you can pass it onto the SDK using the init configuration parameters shown below.

//GDPR COMPLIANCE
config.UserConsent = "1";
config.SubjectToGDPR = "1";
            

UserConsent has a boolean parameter. If you have the user’s consent, set it "1". If you do not have the user's consent, set it "0".

SubjectToGDPR has a boolean parameter. If you know the user is subject to GDPR, set it "1". If you know the user is not subject to GDPR, set it "0".

If you don’t pass the user’s consent or subjectToGDPR to the SDK, the rules described in GDPR have been applied.

To create and show a banner ad run the following code


                    AMR.AMRSDK.loadBanner(AMR.Enums.AMRSDKBannerPosition.BannerPositionTop, true);
                

If you want to show a banner manually after it has loaded, pass false as the second parameter of loadBanner method and wait for the OnBannerReady callback. Then call the following method to show banner.


                    AMR.AMRSDK.showBanner();
                

Call hideBanner method to hide the banner;


AMR.AMRSDK.hideBanner();
                

You can subscribe onBannerReady, onBannerFail or onBannerClick callback functions to catch banner events.


// Banner Callbacks - Optional
AMR.AMRSDK.setOnBannerReady(onBannerReady);
AMR.AMRSDK.setOnBannerFail(onBannerFail);
AMR.AMRSDK.setOnBannerClick(onBannerClick);

public void onBannerReady(string networkName, double ecpm) {}
public void onBannerFail(string error) {}
public void onBannerClick(string networkName) {}
                

Interstitial Ads

To load an Interstitial ad run the following code;


AMR.AMRSDK.loadInterstitial();
                

To show a loaded interstitial run the following code;


if (AMR.AMRSDK.isInterstitialReady())
	AMR.AMRSDK.showInterstitial();
                

As an alternative, if you want to send tag parameter, run the following code;


if (AMR.AMRSDK.isInterstitialReady())
	AMR.AMRSDK.showInterstitial("MyTag");
                

You can subscribe to 5 callback functions OnInterstitialReady, OnInterstitialFail, OnInterstitialShow, OnInterstitialClick and OnInterstitialDismiss to catch interstitial events.


void Start()
{
    // Interstitial Callbacks - Optional


    AMR.AMRSDK.setOnInterstitialReady(OnInterstitialReady);
    AMR.AMRSDK.setOnInterstitialFail(OnInterstitialFail);
    AMR.AMRSDK.setOnInterstitialShow(OnInterstitialShow);
    AMR.AMRSDK.setOnInterstitialClick(OnInterstitialClick);
    AMR.AMRSDK.setOnInterstitialDismiss(OnInterstitialDismiss);
}

// It indicates that the interstitial ad is loaded and ready to show.
public void OnInterstitialReady(string networkName, double ecpm) {}

// It indicates that the interstitial ad received no-fill response from all of its placements. Therefore, the ad can not be shown. You may choose to try loading it again.
public void OnInterstitialFail(string errorMessage) {}

// It indicates that the loaded interstitial ad is shown to the user.
public void OnInterstitialShow() {}

// It indicates that the interstitial ad is clicked.
public void OnInterstitialClick(string networkName) {}

// It indicates that the interstitial ad is closed by clicking cross button/back button
public void OnInterstitialDismiss() {}
                

Reload Ad

You can subscribe to OnInterstitialDismiss callback and reload a new interstitial ad.


void Start()
{
    AMR.AMRSDK.setOnInterstitialDismiss(OnInterstitialDismiss);
}

public void OnInterstitialDismiss()
{
    AMR.AMRSDK.loadInterstitial();
}
                

Rewarded Ads

Rewarded video ads' integration is pretty similar to Interstitial ads with 1 additional event rewardedVideoComplete to reward the user.

To load an rewarded video ad, run the following code;


AMR.AMRSDK.loadRewardedVideo();
                

To show an rewarded video ad, run the following code;


if (AMR.AMRSDK.isRewardedVideoReady())
	AMR.AMRSDK.showRewardedVideo();
                

As an alternative, if you want to send tag parameter, run the following code;


if (AMR.AMRSDK.isRewardedVideoReady())
	AMR.AMRSDK.showRewardedVideo("MyTag");
                

You can subscribe to 6 callback functions OnRewardedVideoReady, OnRewardedVideoFail, OnRewardedVideoShow, OnRewardedVideoClick, OnVideoDismiss and OnVideoComplete to catch rewarded video events.



void Start()
{
    // Rewarded Video Callbacks - Optional
    AMR.AMRSDK.setOnRewardedVideoReady(OnVideoReady);
    AMR.AMRSDK.setOnRewardedVideoFail(OnVideoFail);
    AMR.AMRSDK.setOnRewardedVideoShow(OnVideoShow);
    AMR.AMRSDK.setOnRewardedVideoClick(OnVideoClick);
    AMR.AMRSDK.setOnRewardedVideoDismiss(OnVideoDismiss);
    AMR.AMRSDK.setOnRewardedVideoComplete(OnVideoComplete);
}

// It indicates that the rewarded video ad is loaded and ready to show.
public void OnVideoReady(string networkName, double ecpm) {}

// It indicates that the rewarded video ad received no-fill response from all of its placements.
//Therefore, the ad can not be shown. You may choose to try loading it again.
public void OnVideoFail(string errorMessage) {}

// It indicates that the loaded rewarded video ad is shown to the user.(Note: It does not mean that the user deserves a reward)
// It is immediately called after the loaded ad is shown to the user using AMR.AMRSDK.showRewardedVideo()
public void OnVideoShow() {}

// It indicates that the rewarded video ad is clicked.
public void OnVideoClick(string networkName) {}

// It indicates that the rewarded video ad is closed by clicking cross button/back button.
// It does not mean that the user deserves to receive a reward. You need to check whether OnVideoComplete callback is called or not.
public void OnVideoDismiss() {}

// It indicates that the user deserves to receive a reward. You may need to store this information in a variable and give a reward
// to the user after OnVideoDismiss() callback is called by showing some animations for instance.
// Note: If OnVideoComplete callback is called for the ad, it is always called before OnVideoDismiss() callback.
public void OnVideoComplete() {}
                

Reload Ad

You can subscribe to OnRewardedVideoDismiss callback and reload a new rewarded video ad.


void Start()
{
    AMR.AMRSDK.setOnRewardedVideoDismiss(OnVideoDismiss);
}

public void OnVideoDismiss()
{
    AMR.AMRSDK.loadRewardedVideo();
}
                

Offerwall Ads

To load an offerwall ad, run the following code;


AMR.AMRSDK.loadOfferWall();
                

To show an offerwall ad, run the following code;


if (AMR.AMRSDK.isOfferWallReady())
	AMR.AMRSDK.showOfferWall();
                

As an alternative, if you want to send tag parameter, run the following code;


if (AMR.AMRSDK.isOfferWallReady())
	AMR.AMRSDK.showOfferWall("MyTag");
                

You can subscribe to 3 callback functions OnOfferWallReady, OnOfferWallFail and OnOfferWallDismiss to catch offerwall events.


void Start()
{
    // Offerwall Callbacks - Optional
    AMR.AMRSDK.setOnOfferWallReady(OnOfferWallReady);
    AMR.AMRSDK.setOnOfferWallFail(OnOfferWallFail);
    AMR.AMRSDK.setOnOfferWallDismiss(OnOfferWallDismiss);
}

public void OnOfferWallReady(string networkName, double ecpm) {}
public void OnOfferWallFail(string error) {}
public void OnOfferWallDismiss() {}
                

Spend Virtual Currency


void Start()
{
    // Spend Virtual Currency Callbacks - Optional
    AMR.AMRSDK.setOnDidSpendVirtualCurrency(OnVirtualCurrencyDidSpend);
}

public void OnVirtualCurrencyDidSpend(string networkName, string currency, double amount) {}
            

Extras

Multidex

To enable Multidex on Android please follow the instructions below.

Copy the files inside the zip into Plugins/Android directory.

Open the AndroidManifest inside this directory.

Add " android:name=“com.kokteyl.core.AmrUnityApplication” " to application tag as below.

<application android:name="com.kokteyl.core.AmrUnityApplication"> 

In the Unity Editor, open the Build Settings window (menu: File > Build Settings…)

In the Platform list, select Android

Set the Build System drop-down to Gradle (new)

Open Player Settings

Thick up the Custom Gradle Template checkbox.

consent

Test Suite

You can use Test Suite to test your ad networks with your zone ids.

To use Test Suite in your application, you can use following code;


    // Call method with tested zone ids
    #if UNITY_IPHONE
    AMR.AMRSDK.startTestSuite(new string[] {"IOS_ZONE_ID","ANOTHER_IOS_ZONE_ID"});
    #endif
    #if UNITY_ANDROID
    AMR.AMRSDK.startTestSuite(new string[] {"ANDROID_ZONE_ID","ANOTHER_ANDROID_ZONE_ID"});
    #endif
                    

Android

shadowed image

iOS

shadowed image

In App Purchase Tracking

The following call is used to track purchases with receipt validation:

Android


                    //Product refers UnityEngine.Purchasing class object
AMR.AMRSDK.trackPurchaseForAndroid( product.receipt,
				product.metadata.localizedPrice,
				product.metadata.isoCurrencyCode);
                    

Explanation of parameters:

  • receipt – The purchase receipt for this product
  • localizedPrice – Decimal product price denominated in the currency indicated by isoCurrencySymbol.
  • isoCurrencyCode – Product currency in ISO 4217 format; e.g. TRY or USD.

iOS


                    //Product refers UnityEngine.Purchasing class object
AMR.AMRSDK.trackPurchaseForIOS( product.transactionID,
				product.metadata.localizedPrice,
				product.metadata.isoCurrencyCode);
                    
  • transactionID – A unique identifier for this product's transaction
  • localizedPrice – Decimal product price denominated in the currency indicated by isoCurrencySymbol.
  • isoCurrencyCode – Product currency in ISO 4217 format; e.g. TRY or USD.

Amazon Store


					AMR.AMRSDK.trackPurchaseForAmazon(userId, receiptId, localizedPrice, marketPlace, isoCurrencyCode);
                    

Explanation of parameters:

  • userId (string) – The ID representing a distinct Amazon customer for the Amazon Appstore app: e.g purchaseResponse->userData->userId.
  • receiptId (string) – Unique ID for the purchase: e.g purchaseResponse->receipt->receiptId
  • localizedPrice (decimal) – Decimal product price denominated in the currency indicated by isoCurrencySymbol.
  • marketPlace (string) – Amazon store marketplace country code for the currently logged on user. If you have isoCurrencyCode, you can leave marketPlace null.
  • isoCurrencyCode (string) – ISO currency code for the current purchase response

In App Purchase Tracking Callbacks

You can listen callbacks of your in-app purchases for all platforms as shown below.


AMR.AMRSDK.setTrackPurchaseOnResult(trackPurchaseOnResult);
// You will be notified about the result of your purchase
public void trackPurchaseOnResult(string purchaseId, AMR.Enums.AMRSDKTrackPurchaseResult responseCode)
{
	Debug.Log("ADMOST - trackPurchaseOnResult : " + purchaseId + " " + responseCode);
}

                    

Possible response codes you may have;

  • SuccessfullyValidated(0) : "Valid purchase"
  • FailedToValidate(1) : "Invalid Purchase"
  • Exception(2) : "Temporary exception occurred, will be tried again later"

Setting Application User Id

You can use the following method to set application specific user id in AMR Analytics for enhanced tracking of your users. You have to call this method after initialization.


AMR.AMRSDK.setUserId("<applicationUserId>");
                

Setting Adjust User Id

Follow the official ADJUST documents to integrate AdjustSDK in to your app.

You can optionally use the following method to set adjust user id in Admost Analytics for enhanced tracking of your users. You have to call this method after initialization.


AMR.AMRSDK.setAdjustUserId("<adjustUserId>");
                

GDPR Applicable Check

You can optionally use the following method to check if the user is in a country which is subject to GDPR.



AMR.AMRSDK.setGDPRIsApplicable(isGDPRApplicable);
// The function below will be called just once when you subscribe the callback function as shown above
public void isGDPRApplicable(bool isApplicable)
{
	Debug.Log("ADMOST - isGDPRApplicable : " + isApplicable);
}