iOS SDK: Rewarded video

The myTarget SDK provides the ability to display rewarded video (RV) in your app.

Short (up to 30 sec), non-skippable videos, which a user opts-in to watch in exchange for rewards like virtual goods or in-game gifts. these are perfect for integrating in shop fronts and help increase the retention of the non paying users. Rewarded video ads provide high quality, engaged users to advertisers and highest eCPMs to publishers.

Initialization

To display an RV 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)onVideoCompleteWithInterstitialAd:(MTRGInterstitialAd *)interstitialAd
{
    // This is used by the publisher to disburse the reward to the user
}
- (void)onLeaveApplicationWithInterstitialAd:(MTRGInterstitialAd *)interstitialAd
{
}

Displaying ads

After the ad has loaded successfully, you can start displaying RV ad.

- (void)onLoadWithInterstitialAd:(MTRGInterstitialAd *)interstitialAd
{
    [_ad showWithController:self];
}
Example of an RV
Example of an RV

User Data

For better ad targeting, you can optionally specify the user's gender and age. If your app uses its own localization model, you can also specify the chosen locale in ISO 639-1 format (e.g. "ru", "en", "fr", etc.).

To specify user data, use the customParams property on the created API instance.
@interface YourViewController : UIViewController
@end
 
@implementation YourViewController
{
  MTRGInterstitialAd *_ad;
}
 
- (void)initAd
{
    // Create an instance of MTRGInterstitialAd
    _ad = [MTRGInterstitialAd interstitialAdWithSlotId:YOUR_SLOT_ID];
  
    // Set the age
    _ad.customParams.age = [NSNumber numberWithInt:25];
    // Set the gender
    _ad.customParams.gender = MTRGGenderMale;
}

Samples

Integration samples available in our demo-app on Github.

Mediation with other advertising SDKs

Mediation with the Admob SDK and Mopub SDK is supported for an rewarded video 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 mediation classes to your project.

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

Specify the following values in the Network settings:
Field
Value
CUSTOM EVENT CLASS
MTRGMopubRewardedVideoCustomEvent
CUSTOM EVENT CLASS DATA
{"slotId":"your slot Id"}
Was this article helpful?
Да
Нет