Unity Plugin Integration

Before You Start

  • We support Unity version 2019.4 and up.
  • We support Android Operation Systems Version 4.1(API level 16) and up.
  • We support Xcode 9.0 and up as well as CocoaPods.
  • We suggest creating an OpenMediation account and registering an Android and iOS app.

Please Note! Starting from Android OpenMediation v2.3.1, we have adjusted the advertising API. For details, please refer to Android OM v2.3.1 API changes. You need to use Unity Plugin v2.1.3 and above.

You should run OpenMediation SDK on iOS or Android devices.


This Guideline is intended for publishers who need to monetize for the Unity apps.

OpenMediation 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 OpenMediation platform mediates AdTiming, AdMob, Facebook, UnityAds, Vungle, Tapjoy, AppLovin, AdColony, Chartboost, Pangle, MoPub and ironSource.


Step 1. Add the OpenMediation Unity Package to Your Project

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

  1. Download OpenMediation Unity Plugin
  2. Download OpenMediation Unity Plugin (For Editor Version 2021)
  3. Download OpenMediation Unity Plugin Demo
  4. Make sure your Unity project is opened in the Unity editor.
  5. Import the Unity package.
  • Navigate to Assets -> Import Package -> Custom Package.


  • Select the OpenMediationUnity_vx.x.x.unitypackage file.



Step 2. Unity Integration Manager

Please Note! If your Android application is connected to the SDK of Appsflyer and Vungle at the same time, it will prompt conflict when compiling.Please refer to:Deal with the conflict between AppsFlyer and Vungle.

The OpenMediation Integration Manager tool is based on Google External Dependency Manager for Unity (formerly Play Services Resolver). It will enable you to download the latest versions of OpenMediation SDK and adapters directly from your Unity development platform.


Please Note! The Adapter version number displayed in the Unity integrated management tool is not the iOS/Android OpenMediation***Adapter version number.



  • Unity Developer Version 2017.2 or above
  • For iOS – CocoaPods applied

Manage SDK versions

Once you’ve updated your Unity package for the new SDK and Integration Manager, you’ll be able to view the OpenMediation sub-menu in the Unity menu bar.


To upgrade your SDK or Adapter versions:

  • Go to OpenMediation > Integration Manager (For China Traffic, please select Integration Manager(CN))
  • Choose “Install” or “Update”

If you already have the latest version of OpenMediation SDK or Adapters, the action button will be changed to “Updated”, and will be disabled.


To apply your changes, make sure you use the “Resolve” process. This will download all relevant artifacts, according to your choices.

Manual Resolve
Go to: Assets → External Dependency Manager → Android  Resolver → Resolve

Please Note! If the version of Android SDK  downloaded by Manager is inconsistent with the one declared in the dependency xml, please use Custom Main Gradle Template to solve it. Go to File → Buid Settings → Player Settings → Publishing Settings → Enable the "Custom Main Gradle Template"

This action should be performed after each change in the OpenMediation Integration Manager.

If you’re using Automatic Resolve, all updates will be performed when closing the Integration Manager window.

For Gradle Users

Using OpenMediation Integration Manager for Unity, you will be able to avoid downloading the Android artifacts into your project. Instead, the artifacts will be added to your gradle file during the compilation.

To enable this process, follow these steps:

  1. Go to: Assets →External Dependency Manager → Android  Resolver → Settings 
  2. Select “Patch mainTemplate.gradle”
  3. Save your changes, by pressing “OK”



Make sure that CocoaPods is installed:

Go to: Assets → External Dependency Manager → iOS Resolver → Install CocoaPods


Step 3. Additional Settings for iOS

App Transport Security Settings

  • Add in a Dictionary called 'App Transport Security Settings'. Make sure you add this dictionary on the 'Top Level Key'.

  • Inside this dictionary, add a Boolean called 'Allow Arbitrary Loads' and send it to YESUnityiOSSetting.png

IOpenMediation Automatic Initialization (optional)

If you want to automatically initialize the OpenMediation SDK in your project, you need to check the Automatic Initialization setting in the drop-down box of the OpenMediation column and fill in the AppKey of your project. You can find your application AppKey in the front-end interface of OpenMediation.


Info.plist Settings (optional)

If you added the AdMob SDK using the Unity integration manager tool, you need to add a GADApplicationIdentifier whose string value is your AdMob application ID in the drop-down box of the Admob column. You can find your app ID in the AdMob interface.


Please Note: Be sure to use your actual AdMob app ID instead of the ID listed above .

Important! This step is required since the Google Mobile Ads iOS SDK version 7.42.0. Failure to add this Info.plist entry will result in a crash with the following message: "The Google Mobile Ads SDK was initialized incorrectly."


Step 4. Initialize the Ad Units

Before loading ads, initialize the OpenMediation SDK by calling Om.Agent.init(“appKey”) 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. 

public void Start() {
    Om.Agent.init("Your AppKey");

Implement the Init Events

The OpenMediation Unity Plugin fires init events to inform you of SDK initialization results.

Add the following code to register to the events:

void Start() {
OmEvents.onSdkInitSuccessEvent += SdkInitSuccessEvent;
OmEvents.onSdkInitFailedEvent += SdkInitFailedEvent;

The Plugin will notify the Listener of all possible events listed below: 

void SdkInitSuccessEvent(){

void SdkInitFailedEvent(string error){


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()

Step 5. Implement the ILRD Events(optional)

Add the following code to register to the events (v2.1.0 and above):

public class InitScript : MonoBehaviour {
    void Start() {
        OmEvents.onImpressionDataCallback += ImpressionData;
        OmEvents.onImpressionDataErrorCallback += ImpressionDataError;

The Plugin will notify the Listener of all possible events listed below: 

void ImpressionData(OmImpressionData impressionData) {
void ImpressionDataError(string error) {

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.

Om.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.

Om.Agent.setIap(12.30, 'USD');


Send attribution data to OpenMediation(optional)

If your project also integrates the AppsFlyer SDK, we need you to pass the application attribution data to OpenMediation 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) {

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

public void onAppOpenAttribution(string validateResult) {


Step 6. Setting for iOS 14


If your project uses the OpenMediation Unity Plugin, you only need to open the plugin once. The plugin will automatically add SKAdNetwork content according to your project configuration. You only need to add a description for App Tracking Transparency authorization according to the actual situation of the project.


App Tracking Transparency

  • To display the App Tracking Transparency authorization request for accessing the IDFA, update your Info.plist to add the NSUserTrackingUsageDescription key with a custom message describing your usage.


  • To present the authorization request, call requestTrackingAuthorizationWithCompletionHandler:. We recommend waiting for the completion callback prior to loading ads, so that if the user grants the App Tracking Transparency permission, the OpenMediation SDK can use the IDFA in ad requests.
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/AdSupport.h>
- (void)requestUserIDFA { [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) { // Tracking authorization completed. Start loading ads here.
// [self loadAd];
import AppTrackingTransparency
import AdSupport
func requestUserIDFA() { ATTrackingManager.requestTrackingAuthorization(completionHandler: {status in // Tracking authorization completed. Start loading ads here.
// loadAd()


Set App Tracking Transparency directly in Unity: For details about the connection process for the Unity versions 2019.1 or later, see here.

Step 1: Select Window —> Package Manager, open the Package Manager Manager.


Step 2: On the Package Manager page, click the Packages drop-down box and select Unity Registry.


Step 3: In the Package Manager page, search for the keyword "iOS" in the search box. iOS 14 Advertising Support Package appears in the list on the left. Click the "install" button in the lower right corner to download the Package.


Step 4: Immediately after Step 3, Install, click "Import" to import the iOS 14 Advertising Support Package to your Unity project.


Step 5: After the import is successful, you can see that iOS 14 Advertising Support exists in both Assets and Packages directories. The integration is complete.


Step 6: In the Unity iOS interaction file, add Unity native code.



What’s Next?

Refer to the Ad Unit to integrate Rewarded Video, Interstitial and Banner Ads in your app.
Was this article helpful?
7 out of 11 found this helpful



Article is closed for comments.