iOS Integration Documentation

 

1. API Key

Register your app on appmediation platform for obtaining API key

2. Download SDK and Demo App

2.1 Appmediation SDK

Download the latest appmediation SDK with all the new features and integration here.

2.2 iOS Demo App

Download appmediation demo app with all the new features and integration here.

3. Integration Setup

3.1 Prepare your app

Set up the following keys in your app’s info.plist. This will allow your application to make HTTP requests.

 

<key>NSAppTransportSecurity</key>
 <dict>
     <key>NSAllowsArbitraryLoads</key>
     <true/>
 </dict> 

 

 

3.2 Cocoapods Integration

To integrate with Cocoapods, please add the line below to your podfile and run pod install. New to Cocoapods? learn more here.

pod ‘Appmediation’

3.3 Manual Integration

  1. Download the latest release of appmediation iOS SDK.
  2. Unzip the archive.
  3. Right-click on your project in the Project Navigator menu and select Add Files to “name-of-your-project”…:
  4. Select the appmediation.framework and Resources folder you just extracted and press Add. Make sure to choose Copy items if needed.

  5. Link your application with required libraries.
    • Accelerate
    • AdSupport
    • AudioToolbox
    • AVFoundation
    • CFNetwork
    • CoreData
    • CoreGraphics
    • CoreMedia
    • CoreMotion
    • CoreImage
    • CoreLocation
    • CoreTelephony
    • EventKit
    • EventKitUI
    • Foundation
    • GLKit
    • JavaScriptCore
    • libc++.tbd
    • libsqlite3.0.tbd
    • libxml2.tbd
    • libz.tbd
    • ImageIO
    • MapKit
    • MediaPlayer
    • MessageUI
    • MobileCoreServices
    • QuartzCore
    • Security
    • StoreKit
    • SystemConfiguration
    • UIKit
    • VideoToolbox
    • WebKit
    • WatchConnectivity
  6. Add the -ObjC linker flag to your project by going to Build Settings > Other Linker Flags:

3.4 SDK Initialization

3.4.1 GDPR (EU & EEA Users Only)

You need to obtain end-users’ consent from EU & EEA users before using our advertising services. We have developed two options you can use:

3.4.1.1 Automatic Consent Collection

Appmediation SDK comes with this function enabled by default. With this functionality we check the user’s location and if user is in EU/EEA zone, we show them the consent message. If user is outside of the EU/EEA zone, we do not bother them with GDPR consent message at all!

If you want to disable this functionality and use manual approach, please disable it by:

[AMSDK autoGDPRConsent:NO];

3.4.1.2 Manual Consent Collection

3.4.1.2.1 Consent Window

We have developed a Consent Window option to make it easier to collect end-user consent. Each time when you’re required to collect end-user data consent call Consent Window. This is a perfect solution if you don’t have your own GDPR message.

[AMSDK showConsentWindow];

Note: Please call this window any place other than didFinishLaunchWithOptions method. You don’t need to call setUserConsent method if you used showConsentWindow method.

3.4.1.2.2 Consent Function

If you have your own GDPR message and collect consent from your own view, please pass the collected consent value to this method and you are all set!.

[AMSDK setUserConsent:YES];

3.4.2 SDK Initialization

To initialize Appmediation SDK, import <appmediation/AMSDK.h> in AppDelegate.m of your application and call “[AMSDK initWithAppKey:@”your_app_key”]” in didFinishLaunchWithOptions method.

[AMSDK initWithAppKey:@"your_app_key"];

If you want to use the basic integration for some formats, you should add those ad types for auto-loading after initialization. Please keep in mind that basic integration will reload new ads for itself automatically, so you don’t need to deal with manual steps.

[AMSDK autoloadAdTypes:AppmediationAdTypeInterstitial|AppMediationAdTypeRewarded];

 

3.5 Interstitial Ads

Interstitial ads are full-screen ads that cover the interface of their host app. They can be full screen static interstitial ads or video ads.

3.5.1 Basic

For using basic integration you need to import <appmediation/AMSDK.h> in your class. Later on, at any time, you can call the function below to show interstitial.

[AMSDK showAd:AppmediationAdTypeInterstitial onViewController:self];

 

3.5.2 Advanced

If you are planning to use advanced integration, you should handle creating an instance, loading and presenting yourself.

3.5.2.1 Integration

To access the class for interstitials you should import <appmediation/AMInterstitial.h>

After importing, to initialize the instance:

self.interstitial = [[AMInterstitial alloc] init];

 

To load the instance:

[self.interstitial load];

 

And to show it when it’s ready:

if ([self.interstitial isReady]) {
    [self.interstitial presentFromViewController:self];
 }

 

3.5.2.2 Delegates

If you want more control over the instance, you can comfort AMInterstitialDelegate with your class and implement delegate functions below

-(void)AMInterstitialDidLoad:(AMInterstitial *)interstitial;
-(void)AMInterstitialDidFailToLoad:(AMInterstitial *)interstitial withError:(NSError *)error;
-(void)AMInterstitialDidShow:(AMInterstitial *)interstitial;
-(void)AMInterstitialDidClick:(AMInterstitial *)interstitial;
-(void)AMInterstitialDidClose:(AMInterstitial *)interstitial;

 

3.6 Rewarded Video

Rewarded video ads are full-screen video ads that users have the option of watching in full in exchange for in-app rewards.

3.6.1 Basic

For using basic integration you need to import <appmediation/AMSDK.h> in your class. Later on, at any time, you can call function below to show rewarded video. Please keep in mind that if you rely on video completion to give the reward to the user, you must use advanced integration.

[AMSDK showAd:AppmediationAdTypeRewarded onViewController:self];

 

3.6.2 Advanced

If you are planning to use advanced integration, you should handle creating an instance, loading and presenting yourself.

3.6.2.1 Integration

To access the class for the rewarded video you should import <appmediation/AMRewarded.h>. After importing initialize the instance:

self.rewarded = [[AMRewarded alloc] init];
self.rewarded.delegate = self;

 

To load the instance:

[self.rewarded load];

 

And to show it when it’s ready:

if ([self.rewarded isReady]) {
    [self.rewarded presentFromViewController:self];
 }

 

3.6.2.2 Delegates

If you want more control over the instance, you can comfort AMRewardedDelegate with your class and implement delegate functions below;

-(void)AMRewardedDidLoad:(AMRewarded *)rewarded;
-(void)AMRewardedDidFailToLoad:(AMRewarded *)rewarded withError:(NSError *)error;
-(void)AMRewardedDidShow:(AMRewarded *)rewarded;
-(void)AMRewardedDidClick:(AMRewarded *)rewarded;
-(void)AMRewardedDidClose:(AMRewarded *)rewarded;
-(void)AMRewardedDidComplete:(AMRewarded *)rewarded withReward:(NSString *)name andAmount:(NSString *)amount;

 

3.6.3 Credit Reward

3.6.3.1 Client Side (SDK Callback)

When the video is completed, you will be notified by the delegate below:

-(void)AMRewardedDidComplete:(AMRewarded *)rewarded withReward:(NSString *)name andAmount:(NSString *)amount{
    //reward the user here
 }

3.6.3.2 Server Side (S2S Callback)

We also support server side S2S reward callbacks to securely pass reward data. Server-to-server callbacks are sent to your server when a user has watched an ad. You can use these callbacks to reward players with virtual goods and to e.g. detect and prevent cheating.

By default its not enabled and you can enable them by following steps here.

To use S2S Callback feature, you must set user ID by using [AMSDK setUserIdentifier:@”userID”] method.

 

3.7 Banner Ads

Banner ads are rectangular image or text ads that occupy a spot within an app’s layout. They stay on the screen while users are interacting with the app, and can refresh automatically after a certain period of time.

3.7.1 Basic

For using basic integration you need to import <appmediation/AMSDK.h> in your class. Later on, at any time, you can call the function below to show banner.

[AMSDK showAd:AppmediationAdTypeBanner_Bottom onViewController:self];

 

With basic integration, you can use BannerTop and BannerBottom, but if you want more customized sizing and placement, you have to use the advanced integration.

And to remove it:

[AMSDK removeBanner];

 

3.7.2 Advanced

If you are planning to use advanced integration, you should handle creating an instance, loading and presenting yourself.

3.7.2.1 Integration To access the class for the banner you should import <appmediation/AMBanner.h>. After importing, initialize the instance:

self.banner = [[AMBanner alloc] initWithSize:AMSize_320x50 andPosition:Top rootViewController:YOUR_VIEW_CONTROLLER];
//You can also use custom position, please refer to AMBanner header
self.banner.delegate = self; //If you want to use delegates
[self.view addSubview:self.banner];

 

To load:

[self.banner load];

 

And to remove:

[self.banner remove];

 

3.7.2.2 Delegates

If you want more control over the instance, you can comfort AMBannerDelegate with your class and implement delegate functions below;

-(void)AMBannerDidLoad:(AMBanner *)banner;
-(void)AMBannerDidFailToLoad:(AMBanner *)banner withError:(NSError *)error;
-(void)AMBannerDidShow:(AMBanner *)banner;
-(void)AMBannerDidClick:(AMBanner *)banner; 

 

4. Advanced Features

4.1 Test Mode

It provides the functionality to display test ads for integration testing and 100% fill. Please set this value before initialization call as shown in example below;

[AMSDK setTestMode:YES];
[AMSDK initWithAppKey:@"your_app_key"];

 

*testMode is set to NO by default.

4.2 Audience Data

It provides the functionality to pass user data for more accurate ad targeting.

Function Name Field Type Field Description
setGender String User Gender
setAge Integer User Age
setLanguage String User Language
setKeywords String Interests

5. Best Practices

5.1 Support All Orientations

Our partner SDK’s recommends supporting all orientations globally to deliver best performance metrics. Please note this requirement didn’t interface with your application’s interface settings. To enable this just override the global settings in your view controllers’ supportedInterfaceOrientations method.

There are 2 quick ways to achieve this;

  • Go to your application target’s General tab and select all possible orientations from there.

  • Open your AppDelegate class and override the application:supportedInterfaceOrientationsForWindow: method as shown below:

    @implementation AppDelegate
    -(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
        return UIInterfaceOrientationMaskAll;
    }

Please note that this setting does not dictate your applications supported orientations, you just have to override the global settings in your view controllers’ supportedInterfaceOrientations method.

6. Third-Party Integration Versions

 

Network Name Version Supported AMSDK version
Unity  3.0.0  ≥1.11.2
Tapjoy  12.2.0  ≥1.11.2
Applovin  5.0.0  ≥1.0.0
Inmobi  7.2.1  ≥1.11.2
Mobvista  4.7.0  ≥1.11.2
StartApp  3.9.0  ≥1.11.2
Chartboost  7.3.0  ≥1.11.2
Vungle  6.3.2  ≥1.11.2
AdMob  7.36.0  ≥1.11.2
AdColony  3.3.6  ≥1.11.2
Facebook  5.1.0  ≥1.11.2
MyTarget  4.8.6  ≥1.11.2