iOS SDK Integration

Before You Start

We support iOS version 9+. In case you use Xcode version lower than 9.3, we suggest archiving with 'bitcode' disabled.

Importants!The adapters for each Ad Network in the iOS SDK are modular, which means that 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 OpenMediation 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.

 

Overview

This Guideline introduces the integration of OpenMediation SDK in iOS 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, TikTok, Mintegral, GDT and IronSource.

 

Step 1. Add the SDK to Your Project

OpenMediation supports both CocoaPods and manual download for SDK integration:

CocoaPods

CocoaPods is a dependency manager for Objective-C and Swift; it automates and simplifies the SDK integration process. See the CocoaPods Guide on Getting Started and Using CocoaPods for more information.

To integrate our SDK with CocoaPods, enter the following line in your podfile:

pod 'OpenMediation','2.5.0'

 

Clone the Git Repository

You can clone the Git repository as follows:

git clone git://github.com/AdTiming/OpenMediation-iOS.git

 

Swift Package Manager

We started to support Swift Package Manager since OpenMediation V2.0.5.

1. In Xcode, click File > Swift Packages > Add Package Dependency.

2. In the dialog that appears, enter the repository URL: https://github.com/AdTiming/OpenMediation-iOS.git.

WechatIMG51.png

3. In Version, select Up to Next Major and the default option.

WechatIMG52.png

4. Complete the prompts to select the libraries you want to use in your project.

WechatIMG53.png

 

Manual Download SDK

You can get the OpenMediation SDK source code and demo application through the GitHub repository.

Download OpenMediation SDK

 

Step 2. Build Settings

1. Add Linker Flags

  • Add the following linker flag to the build settings at:
    Target ➣ Build Settings ➣ Linking ➣ Other Linker Flags:
-ObjC

2. 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 YES.

    111111.png

Step 3. Initialize the OpenMediation SDK

@import OpenMediaton
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    [OpenMediation initWithAppKey:@"YOUR_OPENMEDIATION_APP_KEY"];
}
import OpenMediation
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:[UIApplication.LaunchOptionsKey: Any]?) -> Bool {    
  OpenMediation.initWithAppKey("YOUR_OPENMEDIATION_APP_KEY")
}

 

Initialize the OpenMediation SDK with AdUnits

You can specify one or more ad types for initialization SDK, and we recommend this approach as it will only fetch the specific ad units you define in the adUnits parameter. The adUnits parameter is a string array. If you are using a method that does not have an ADType parameter(Step3), the SDK preloads the Interstitial and RewardedVideo.

1. Preload multiple ad types

[OpenMediation initWithAppKey:@"YOUR_OPENMEDIATION_APP_KEY" adFormat:(OpenMediationAdFormatInterstitiall|OpenMediationAdFormatRewarded)];
OpenMediation.initWithAppKey("YOUR_OPENMEDIATION_APP_KEY", adFormat:OpenMediationAdFormat(rawValue: OpenMediationAdFormat.interstitial.rawValue | OpenMediationAdFormat.rewardedVideo.rawValue)!)

2. Preload one ad type

[OpenMediation initWithAppKey:@"YOUR_OPENMEDIATION_APP_KEY" adFormat:OpenMediationAdFormatInterstitiall;
OpenMediation.initWithAppKey("YOUR_OPENMEDIATION_APP_KEY", adFormat:OpenMediationAdFormat.interstitial)

 

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:

For apps using AppsFlyer SDK version 5 and above 

- (void)onConversionDataSuccess:(NSDictionary *)conversionInfo {    
  /// Send AppsFlyer conversion data    
  [OpenMediation sendAFConversionData:conversionInfo];
}
func onConversionDataSuccess(_conversionInfo: NSDictionary) {    
   /// Send AppsFlyer conversion data    
   OpenMediation.sendAdConversionData(conversionInfo)
}

 

For apps using AppsFlyer SDK version 4 and below

- (void)onConversionDataReceived:(NSDictionary *)installData {    
  /// Send AppsFlyer conversion data    
  [OpenMediation sendAFConversionData:installData];
}
func onConversionDataSuccess(_installData: NSDictionary) {    
   /// Send AppsFlyer conversion data    
   OpenMediation.sendAFConversionData(installData)
}

 

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

- (void)onAppOpenAttribution:(NSDictionary *)attributionData {    
  /// Send AppFlyer deep link attribution data    
  [OpenMediation sendAFDeepLinkData:attributionData];
}
func onConversionDataSuccess(_attributionDate: NSDictionary) {    
   /// Send AppsFlyer conversion data    
   OpenMediation.sendAFDeepLinkData(attributionData)
}

 

Step 4. Use the Test Suite to test the integration

1. Install

The aggregation function test suite needs to be installed using Cocoapods. Please add the following code to your Podfile:

pod 'OpenMediationTestSuite', '1.4.0

 

2. Start the aggregation function test suite

#import <OMTestSuite/OMTestSuite.h>
[OMTestSuite presentWithAppKey:@"YOUR_OPENMEDIATION_APP_KEY" onViewController:YOUR_CONTROLLER];
import OMTestSuite
OMTestSuite.present(withAppKey:"YOUR_OPENMEDIATION_APP_KEY", on:YOUR_CONTROLLER)

You can get more help through the Test Suite Tool chapter.

 

What’s Next?

1. Integrate our Rewarded Video, Interstitial, Banner and Native Ads in your app.
2. Follow 
our Add Mediation Networks and Mediation Network Guides to mediation networks.
3.
After completing the above integration work, you can use OpenMediation Test Suite tool to check whether the SDK aggregation integration is corrects.

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

Comments

0 comments

Article is closed for comments.