Adx3
EN
EN
  • Introduction to Broearn Ads Operation
    • Introduction to Broearn Ads Operation(SSP)
      • Login Operation
      • Website
      • Apps-For Android
      • Withdraw
      • Advertising Statistics
      • User Center
    • Introduction to Broearn Ads Operation (DSP)
      • Login Operation
      • Top-up
      • Ad Campaign Management
      • Ad Management
      • Advertising Statistics and Data Analysis
      • User Center
    • Adx3-Agent system manual(AGENT)
      • Log In
      • Add Account
      • Capital Account
      • Data Review
  • interface documentation
    • Monitor incident escalation(DSP)
    • Monitor incident escalation(SSP)
    • CPA, CPS Event Report
    • ANDRIOD
      • Start
        • Getting Started Guide
        • Test
      • Ad formats
        • Banner
        • Interstitial
        • Rewarded
        • APP Open
        • Native
        • Multiple
    • IOS
      • Get started
        • Getting Started Guide
        • Test
      • Ad formats
        • App Open
        • Interstital
        • Banner
        • Rewarded
        • Native
        • Multiple
  • FAQ
    • FAQ
Powered by GitBook
On this page
  • Prerequisites
  • Always test with test ads
  • Implementation
  1. interface documentation
  2. IOS
  3. Ad formats

Rewarded

PreviousBannerNextNative

Last updated 1 year ago

Rewarded ads are ads that users have the option of interacting with in exchange for in-app rewards. This guide shows you how to integrate rewarded ads from Adx3 into an iOS app.

Prerequisites

  • Complete the .

Always test with test ads

When building and testing your apps, make sure you use test ads rather than live, production ads. Failure to do so can lead to suspension of your account. The easiest way to load test ads is to use our dedicated test ad unit ID for app-rewarded ads:

63a573b533f6f

It's been specially configured to return test ads for every request, and you're free to use it in your own apps while coding, testing, and debugging. Just make sure you replace it with your own ad unit ID before publishing your app.

Implementation

The main steps to integrate interstitial ads are:

  • Load an ad.

  • Register for callbacks.

  • Display the ad and handle the event.

Load an ad

Loading an ad is accomplished using the static loadAdWithPlacementID:userId:delegate: method on the Adx3RewardAd class. The load method requires your ad unit ID, a userId object, and a delegate object which gets called when ad loading succeeds or fails. UserId object cannot be passed, nor can your custom user identifier. The below example shows how to load an Adx3RewardAd in your ViewController class.

import UIKit

class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        loadRewardAd()
        // Do any additional setup after loading the view.
    }
    
    func loadRewardAd() {
        Adx3RewardAd.sharedManager().load(withPlacementID: "Your Placement ID", userId: "", delegate: self)
    }
}
#import "Adx3Framework/Adx3Ad.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadRewardAd];
}

- (void)loadRewardAd {
    [[Adx3RewardAd sharedManager] loadAdWithPlacementID:@"Your Placement ID" userId:@"" delegate:self];
}

@end

Register for callbacks

You should rely on the Adx3RewardDelegate (optional) to handle display events and request events. The following code shows how to implement the protocol:

import UIKit

class ViewController: UIViewController, Adx3RewardDelegate {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }
}

extension ViewController {
    
    func didFinishLoadingAD(withPlacementID placementID: String!) {
        print("----Interstitial AD Load Finish----")
    }
    
    func didFailToLoadAD(withPlacementID placementID: String!, error: Error!) {
        print("----\(error.debugDescription)----")
    }
    
    func rewardDidShow(forPlacementID placementID: String!, extra: [AnyHashable : Any]!) {
        
    }
    
    func rewardDidClick(forPlacementID placementID: String!, extra: [AnyHashable : Any]!) {
        
    }
    
    func rewardDidClose(forPlacementID placementID: String!, extra: [AnyHashable : Any]!) {
        
    }
    
    func rewardDidEndPlayingVideo(forPlacementID placementID: String!, extra: [AnyHashable : Any]!) {
    
    }
    
    func rewardDidStartPlayingVideo(forPlacementID placementID: String!, extra: [AnyHashable : Any]!) {
        
    }
    
    func rewardFailedToShow(forPlacementID placementID: String!, error: Error!, extra: [AnyHashable : Any]!) {
        
    }
    
    func rewardDidFailToPlayVideo(forPlacementID placementID: String!, error: Error!, extra: [AnyHashable : Any]!) {
        
    }
    
}
#import "Adx3Framework/Adx3Ad.h"

@interface ViewController () <Adx3RewardDelegate>

@end

@implementation ViewController

-(void)didFinishLoadingADWithPlacementID:(NSString *)placementID {
    NSLog(@"----Reward AD Load Finish----");
}

-(void)didFailToLoadADWithPlacementID:(NSString*)placementID error:(NSError*)error {
    NSLog(@"----%@----",error.description);
}

-(void)rewardDidShowForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {

}

-(void)rewardFailedToShowForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary*)extra {

}

-(void)rewardDidStartPlayingVideoForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {

}

-(void)rewardDidEndPlayingVideoForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {

}

-(void)rewardDidFailToPlayVideoForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary*)extra {

}

-(void)rewardDidCloseForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {

}

-(void)rewardDidClickForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {

}

@end

Display the ad

Before displaying a rewarded ad to users, you must present the user with an explicit choice to view rewarded ad content in exchange for a reward. Rewarded ads must always be an opt-in experience.

The following code presents the best method for displaying a rewarded ad.

func showRewardAd() {
    if Adx3RewardAd.sharedManager().rewardIsReady() {
        Adx3RewardAd.sharedManager().showReward(in: self, delegate: self)
    }
}
- (void)showRewardAd {
     if ([[Adx3RewardAd sharedManager] rewardIsReady]) {
        [[Adx3RewardAd sharedManager] showRewardInViewController:self delegate:self];
    }
}
Getting Started Guide