1. Initialising VMaxAdSDK
it is mandatory to initialise the newly introduced VMaxAdSDK. This needs to be done as early as possible in the application lifecycle. The VMaxAdSDK asynchronously gratifies rewards via the VMaxAdSDKDelegate. Thus it is necessary to conform to the VMaxAdSDKDelegate protocol to receive rewards and further gratify users of your app. Attempt to request rewarded interstitial ads only on successful initialization of the VMaxAdSDK.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
@interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [VMaxAdSDK initWithAccountKey:@"YOUR_ACCOUNT_KEY" delegate:self onCompletion:^(NSError *error) { if(error) { NSLog(@"VMAX SDK Initialisation failed"); } else { // SDK init succeeded NSLog(@"VMAX SDK Initialised"); // Request rewarded interstitial ads } }]; return YES; } #pragma mark VMaxAdSDKDelegate - - (void)onAdReward:(NSInteger)reward { NSLog(@"reward: %ld", (long)reward); } |
2. Adding Firebase dependencies
You are also required to add Firebase dependencies to your project. You can download them from Firebase’ official site or add them from the VMAX iOS SDK zip file by dragging & dropping them into your Xcode project.
The following files & frameworks are required:
- FirebaseAnalytics.framework
- FirebaseCore.framework
- FirebaseInstanceID.framework
- GoogleInterchangeUtilities.framework
- GoogleSymbolUtilities.framework
- GoogleToolboxForMac.framework
- FirebaseAuth.framework
- GTMSessionFetcher.framework
- FirebaseDatabase.framework
- Firebase.h
Requesting Rewarded Interstitial ads
After completing the prerequisites to request rewarded interstitial ads, you are required to initialise an adview with the initWithRewardedInterstitialAdspotID:viewController:withAdUXType initializer. Do not attempt to initialise using the standard initWithAdspotID:viewController:withAdUXType initializer as it will have adverse effects and result in ad failure.
Create an instance of the VMaxAdView and conform to the delegate.
Creating the Ad View
1 2 3 4 5 6 7 |
// Put your Rewarded Interstitial Adsopt id here. Also provide the Topmost view controller in order to present the full screen ads. adView = [[VMaxAdView alloc] initWithRewardedInterstitialAdspotID:YOUR_ADSPOT_ID viewController: self withAdUXType: kVMaxAdUX_Interstitial]; // Set the delegate to class which confirms to VMaxAdDelegate protocol. adView.delegate = self; // Make ad request. [adView cacheAd]; |
1 2 3 4 5 6 |
self.adView = VMaxAdView (initWithRewardedInterstitialAdspotID: "ADSPOT_ID", viewController: self, withAdUXType: kVMaxAdUX_Interstitial) self.adView.delegate = self // Add the adview to your view hierarchy. self.view.addSubview(self.adView) self.adView.cacheAd() |
Note:
From SDK Version 3.6.10 and onwards there are some delegate changes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
Removed Delegates @required - (void)onAdDismissed:(VMaxAdView *)adView; - (void)onAdEnd:(VMaxAdView *)adView completed:(BOOL)completed reward:(NSInteger)reward; @optional - (void)onAdStarted:(VMaxAdView *)adView; - (void)onAdExpand:(VMaxAdView *)adView; - (void)onAdCollapsed:(VMaxAdView *)adView; - (void)onAdInteracted:(VMaxAdView *)adView; - (void)onAdInterrupted:(VMaxAdView *)adView; - (void)onAdLeftApplication:(VMaxAdView *)adView; Added Delegates @required - (void)onAdClose; - (void)onAdMediaEnd:(BOOL)completed reward:(NSInteger)reward; @optional - (void)onAdMediaStart; - (void)onAdMediaExpand; - (void)onAdMediaCollapse; - (void)onAdClick; |