Interstitial Ads for iOS

The myTarget SDK provides the ability to display an interstitial ads in your app.

Initialization

To display an interstitial ad in your app, create an instance of the MTRGInterstitialAd class. You must specify your slotId when creating an instance.
@interface YourViewController : UIViewController
@end
 
@implementation YourViewController
{
  MTRGInterstitialAd *_ad;
}
 
- (void)initAd
{
    // Enabling debug mode
    // [MTRGInterstitialAd setDebugMode:YES];
     
    // Create an instance of MTRGInterstitialAd
    _ad = [MTRGInterstitialAd interstitialAdWithSlotId:YOUR_SLOT_ID];
}

Loading ads

To receive notifications (such as ad load succeeded, ad load failed, or ad clicked), you must set a delegate, which implements the MTRGInterstitialAdDelegate protocol, on the MTRGInterstitialAd instance. Then you can start loading ad.
@interface YourViewController : UIViewController <MTRGInterstitialAdDelegate>
@end
 
@implementation YourViewController
{
  MTRGInterstitialAd *_ad;
}
 
- (void)initAd
{
    // Create an instance of MTRGInterstitialAd
    _ad = [MTRGInterstitialAd interstitialAdWithSlotId:YOUR_SLOT_ID];
     
    // Set the delegate
    _ad.delegate = self;
     
    // Start loading ad
    [_ad load];
}
  
- (void)onLoadWithInterstitialAd:(MTRGInterstitialAd *)interstitialAd
{
}
  
- (void)onNoAdWithReason:(NSString *)reason interstitialAd:(MTRGInterstitialAd *)interstitialAd
{
}
  
- (void)onDisplayWithInterstitialAd:(MTRGInterstitialAd *)interstitialAd
{
}
 
- (void)onClickWithInterstitialAd:(MTRGInterstitialAd *)interstitialAd
{
}
 
- (void)onCloseWithInterstitialAd:(MTRGInterstitialAd *)interstitialAd
{
}
  
- (void)onLeaveApplicationWithInterstitialAd:(MTRGInterstitialAd *)interstitialAd
{
}

Displaying ads

After the ad has loaded successfully, you can start displaying interstitial ad.
- (void)onLoadWithInterstitialAd:(MTRGInterstitialAd *)interstitialAd
{
    [_ad showWithController:self];
}
Example of an interstitial banner

Mediation with other advertising SDKs

Mediation with the Admob SDK and Mopub SDK is supported for an interstitial ads.

AdMob mediation

myTarget is a certified partner of Google Mediation.

Requirements
- Xcode 11 or higher
- iOS Deployment target of 9.0 or higher
- Google Mobile Ads SDK 7.57.0 or higher

Brief instruction for mediation myTarget via Admob
- Configure mediation settings for your Admob ad unit
- Import myTarget SDK and adapter (myTarget SDK and Google Mobile Ads SDK will e installed automatically in case if you use CocoaPods dependencies manager)
- Test integration

Please read full instruction here: https://developers.google.com/admob/ios/mediation/mytarget#step_2_configure_mediation_settings_for_your_ad_unit

Mopub mediation

Mediation with Mopub SDK requires adding following files to your project: https://github.com/myTargetSDK/mytarget-ios/tree/master/mediation/mopub

Mediation is configured at http://www.mopub.com/

Specify the following values in the Network settings:
Field
Value
CUSTOM EVENT CLASS
MTRGMopubInterstitialCustomEvent
CUSTOM EVENT CLASS DATA
{"slotId":"<your slot Id>"}
Was this article helpful?
Yes
No