Skip to main content

Rewarded Ads

1. Load an ad#

  • Loading ads requires some time, so it is recommended to pre-load the ads before displaying them.
  • AdUnitID is the Ad Unit ID created in the TradPlus backend. SDK will fetch the configuration and request ads according to the Ad Unit ID.
#import <TradPlusAds/TradPlusAdRewarded.h>
self.rewardedVideoAd = [[TradPlusAdRewarded alloc] init];
[self.rewardedVideoAd setAdUnitID:@"Your Ad Unit ID"];
self.rewardedVideoAd.delegate = self;
[self.rewardedVideoAd loadAd];

2. Show RewardVideo Ad#

  • Call the isAdReady method to check if there is an available ad. When there is an available ad, call the showAdWithSceneId: method to display the ad.
  • SceneId is the Ad Scene ID. The default is nil.
if (self.rewardedVideoAd.isAdReady)
{
[self.rewardedVideoAd showAdWithSceneId:nil];
}

3. Register TradPlusADRewardedDelegate Callback#

  • Ad event callbacks need to be registered before displaying an ad. Get callbacks for ad loading, ad show, ad click, ad close, etc.
//Ad loaded successfully. Callback when the first ad source is loaded successfully. The loading process will only be called once.
- (void)tpRewardedAdLoaded:(NSDictionary *)adInfo;
//Ad loading failed
//tpRewardedAdOneLayerLoad:didFailWithError:returns the error message of the third-party source
- (void)tpRewardedAdLoadFailWithError:(NSError *)error;
//Ad show succeeded. Valid show recognized by the third party
- (void)tpRewardedAdImpression:(NSDictionary *)adInfo;
//Ad show failed
- (void)tpRewardedAdShow:(NSDictionary *)adInfo didFailWithError:(NSError *)error;
//Ad clicked
- (void)tpRewardedAdClicked:(NSDictionary *)adInfo;
//Ad closed
- (void)tpRewardedAdDismissed:(NSDictionary *)adInfo;
//Reward completed
- (void)tpRewardedAdReward:(NSDictionary *)adInfo;

4. Server-side Reward Verification#

  • TPSDK will pass it to the third-party SDK through this API.
// @param userID user unique identifier, required
// @param customData additional information, fill in according to platform requirements
- (void)setServerSideVerificationOptionsWithUserID:(nonnull NSString *)userID customData:(nullable NSString *)customData;

5. Integration Reference#

Reference: TradPlusAdRewardedViewController