Enabling rewarded ads

A rewarded ad is a configurable full-screen ad. The user gets a reward for viewing the ad.

To enable advertising:

  1. Add the import:

    #import <YandexMobileMetrica/YMARewardedAd.h>
  2. Create @property for storing the link to the ad:

    @property (nonatomic, strong) YMARewardedAd *rewardedAd;
  3. Initialize the ad:
    self.rewardedAd = [[YMARewardedAd alloc] initWithBlockID:<your unique BlockID>];
    self.rewardedAd.delegate = self;

    BlockId is a unique identifier in the R-M-XXXXXX-Y format, which is assigned in the Partner interface.

    In addition, self must conform to the YMARewardedAdDelegate protocol.

  4. Set the userID if you use reward confirmation on the server side (“server-side reward”).

    self.rewardedAd.userID = <your user ID>

    userID — The unique app user ID.

  5. Load an ad.
    [self.rewardedAd load];

    Optionally, you can use the YMAAdRequest class to transmit the data for targeting.

    The ad must be pre-loaded in the same orientation as it will be shown (otherwise, the ad will not be shown because the banner size won't match the screen size).
  6. Start displaying ads by using this method:

    – rewardedAdDidLoadAd:
         [rewardedAd presentFromViewController:self];
  7. If you are using the “client-side reward” mechanism, implement the – rewardedAd:didReward: delegate method. It is called when the impression is registered and the user can be rewarded for viewing the ad. Use this chance to give the reward to the app user.

  8. You can optionally enable logging by using the enableLogging method. If an impression wasn't registered, a message appears in the console.

    To find out why ads aren't working correctly, use the method

    – rewardedAdDidFailToPresentAd:error:

    For error descriptions, see YMAAdErrorCode.

To see how ads will be displayed in the app, use the sample Block ID:
  • R-M-DEMO-rewarded-server-side-mediation
  • R-M-DEMO-rewarded-client-side-mediation
  • R-M-DEMO-rewarded-server-side-rtb
  • R-M-DEMO-rewarded-client-side-rtb