Rewarded Video Ads
Rewarded video ads are a great way to offer users an incentive to stay engaged in your app, while earning more ad revenue. The reward generally comes in the form of in-game currency (gold, coins, power-ups) and is distributed to the user after a successful video completion.
MoPub’s mediation solution officially supports rewarded videos from popular ad networks. We give you the flexibility to work with these popular ad networks without any extra integration with network SDKs. We recommend placing rewarded video ads where your users are already engaging with in-app purchases or in locations where users may be seeking an in-app reward, such as the end of a game or at currency redemption points. Once your users have finished watching the video ad, you can designate the reward they will receive.
- Before integrating rewarded video ads in your app, you’ll need to go through the steps in our Getting Started Guide, create an account on MoPub, and integrate the SDK into your project.
- Add a rewarded video ad unit to your app in the MoPub dashboard.
- If you use mediation, make sure you have added the ad network SDKs and the corresponding adapters you wish to use to your app.
1. Import the required headers
- Import the
- Import the
2. Initialize the MoPub SDK
Initialize the MoPub SDK on app launches. You can typically do that in your AppDelegate. Note: If you have been using the
[[MoPub sharedInstance] initializeRewardedVideoWithGlobalMediationSettings] API, it has been deprecated in the 5.0.0 SDK release, so make sure to start using the new initialization API.
You do not need to explicitly initialize any mediated rewarded video network SDKs via their APIs — the MoPub SDK properly handles that logic on your behalf.
3. Request and cache the rewarded video
Cache a rewarded video for the given ad unit ID (often a placement within the app, e.g. game-over screen or in-app store):
4. Show the rewarded video
Check if the rewarded video has been fully cached by calling
hasAdAvailableForAdUnitID: before offering to display it to the user.
Show the rewarded video when the user clicks to watch it:
[MPRewardedVideo presentRewardedVideoAdForAdUnitID:@"YOUR_AD_UNIT_ID" fromViewController:self];
6. Optional: Implement the delegate methods
MPRewardedVideoDelegate includes a variety of optional callbacks that you can use to be notified of events, e.g. when a rewarded video has successfully loaded, or when a rewarded video is about to appear. Check out the
MPRewardedVideoDelegate for the following methods
- (void)rewardedVideoAdDidLoadForAdUnitID:(NSString *)adUnitID - (void)rewardedVideoAdDidFailToPlayForAdUnitID:(NSString *)adUnitID error:(NSError *)error; - (void)rewardedVideoAdWillAppearForAdUnitID:(NSString *)adUnitID - (void)rewardedVideoAdDidAppearForAdUnitID:(NSString *)adUnitID - (void)rewardedVideoAdWillDisappearForAdUnitID:(NSString *)adUnitID - (void)rewardedVideoAdDidDisappearForAdUnitID:(NSString *)adUnitID - (void)rewardedVideoAdDidExpireForAdUnitID:(NSString *)adUnitID - (void)rewardedVideoAdDidReceiveTapEventForAdUnitID:(NSString *)adUnitID - (void)rewardedVideoAdShouldRewardForAdUnitID:(NSString *)adUnitID reward:(MPRewardedVideoReward *)reward - (void)rewardedVideoAdWillLeaveApplicationForAdUnitID:(NSString *)adUnitID;
Here are a few examples of how callacks can be useful:
- You can be notified that a rewarded video was fetched successfully by implementing
- If you’d like to pause the game whenever you present a rewarded video, and resume it when the rewarded video is dismissed, you can accomplish it using the
Advanced Use Cases
Mediation settings enable you to pass in third-party network specific settings and can be provided as additional parameters during the rewarded video initialization call. For Vungle, during Unity and Chartboost mediation, this is the only mechanism by which a user ID or customer ID can be specified in networks’ server-side callbacks.
You may pass in an array of configured global mediation objects. These objects are used to configure the underlying ad networks which in turn affects all ads for the specific network. Any given ad network may or may not have global mediation settings classes. Using a global mediation settings class involves:
- Creating an instance of the global settings class for an ad networks that may supply ads to your application.
- Configuring the properties on the objects.
- Passing them inside an array when initializing rewarded video.
Furthermore, you may pass in instance mediation settings when calling
+loadRewardedVideoAdWithAdUnitID:withMediationSettings:. These settings apply to the ad network for the ad unit ID you are using to load an ad. Any given ad network may or may not have instance mediation settings classes. Using a instance mediation settings class involves:
- Creating an instance of the mediation settings class for ad networks that may be loaded for your ad unit ID.
- Configuring the properties on the objects.
- Passing them inside an array when loading a rewarded video.
Mediated Network Pre-initialization
Passing in a list of rewarded video network classes that extend from
MPMediationSdkInitializable will automatically try to pre-initialize those rewarded networks, in the order passed in, with the last cached initialization parameters for each network. If no cached initialization parameters are found for a network, pre-initialization for that network is skipped.
By pre-initializing the network SDKs, this gives the network the necessary lead time between SDK initialization and ad request to ensure a successful ad request. Every successful call to
loadRewardedVideoAdWithAdUnitID will update the initialization parameters in the cache for that network.
To utilize the rewarded video pre-initialization API, follow the instructions to do so when initializing the MoPub SDK. To opt out of the pre-initialization API, simply pass in an empty list.
Note: The existing on-demand network SDK initialization can be combined with this partial pre-initialization call.
Passing Custom Data
There may be cases where your reward server will need additional information to determine an appropriate reward for the user. When the rewarded video is presented, the app can call
+presentRewardedVideoAdForAdUnitID:fromViewController:withReward:customData:, and include an optional string containing custom data. The optional custom data will be sent as part of the URL in the server-to-server callback.
- It is recommended that the custom data string not exceed 8kb in size as this will significantly degrade performance. Try to keep the custom data payload as small as possible.
- Custom data will only be passed if the ad unit has been setup with a server side callback.
In addition to specifying the custom data at presentation time, the server-side callback URL in the MoPub dashboard will also need to include a query parameter that uses the
%%CUSTOM_DATA%% macro. For example:
- Making concurrent ad requests using the same ad unit IDs is not recommended.
Last updated July 27, 2018
TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.
© 2018 MoPub Inc.