Home / iOS / Objective C / Rewarded

Using the SDK

Rewarded

Rewarded is an ad shown in full-screen video, with the option to close it appear when the video is completed . Add the following lines to the ViewController.h file:

#import <TappxFramework/TappxAds.h>

@interface ViewController : UIViewController <TappxRewardedViewControllerDelegate>

@property (retain, nonatomic) TappxRewardedViewController* tappxRewardedViewController;

@end

Now you need to initialize the rewarded in the ViewController.m file. Example:

#import "ViewController.h"
#import <TappxFramework/TappxAds.h>

@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
_tappxRewardedViewController = [[TappxRewardedViewController alloc] initWithDelegate:self];
[_tappxRewardedViewController setAutoShowWhenReady:YES];
[_tappxRewardedViewController load];
}

-(nonnull UIViewController*)presentViewController{
return self;
}

- (void)present:(nonnull UIViewController*)viewController{
[self presentViewController:viewController animated:true completion:nil];
}

@end

If you want to request a rewarded to be shown as soon as it's ready, you can use this method:

[_tappxRewardedViewController setAutoShowWhenReady:YES];

If you want to have more control, you can use the following five options: load, isReady, show, setPopupMessage and setCountDownMessage.

load is the request to get the ad and load all the information so you can show the ad.

[_tappxRewardedViewController load];

isReady allows you to check if the ad is ready to be shown. You will receive a "true" if the ad is ready and a "false" if not.

[_tappxRewardedViewController isReady];

show allows you to display the rewarded ad that has loaded previously.

[_tappxRewardedViewController show];

setPopupMessage allows you to configure text messages in the Pop-Up.

[self.tappxRewardedViewController setPopupMessage:@"Text Message" andAcceptButton:@"Text Button Accept" andCancelButton:@"Text Button Cancel"];

setCountDownMessage allows you to configure text messages in the Countdown.

[self.tappxRewardedViewController setCountDownMessage:@"Text Before Numbers" andAfterTime:@"Text After Second Numbers"];

Delegates

You can add listener events into the rewarded to be notified when a specific event happens in the ad. Here you have examples:

- (void) tappxRewardedViewControllerDidFinishLoad:(nonnull TappxRewardedViewController*) viewController {
NSLog(@"tappxRewardedViewControllerDidFinishLoad method");
}

- (void) tappxRewardedViewControllerDidFail:(nonnull TappxRewardedViewController*) viewController withError:(nonnull TappxErrorAd*) error {
NSLog(@"tappxRewardedViewControllerDidFail method");
}

- (void) tappxRewardedViewControllerClicked:(nonnull TappxRewardedViewController*) viewController {
NSLog(@"tappxRewardedViewControllerClicked method");
}

- (void) tappxRewardedViewControllerPlaybackFailed:(nonnull TappxRewardedViewController*) viewController {
NSLog(@"tappxRewardedViewControllerPlaybackFailed method");
}

- (void) tappxRewardedViewControllerVideoClosed:(nonnull TappxRewardedViewController*) viewController {
NSLog(@"tappxRewardedViewControllerVideoClosed method");
}

- (void) tappxRewardedViewControllerVideoCompleted:(nonnull TappxRewardedViewController*) viewController {
NSLog(@"tappxRewardedViewControllerVideoCompleted method");
}

- (void)tappxRewardedViewControllerDidAppear:(TappxRewardedViewController *)viewController {
NSLog(@"tappxRewardedViewControllerDidAppear method");
}

- (void)tappxRewardedViewControllerDismissed:(TappxRewardedViewController *)viewController {
NSLog(@"tappxRewardedViewControllerDismissed method");
}

- (void)tappxRewardedViewControllerUserDidEarnReward:(TappxRewardedViewController *)viewController {
NSLog(@"tappxRewardedViewControllerUserDidEarnReward method");
}