320x50px, applicable on mobile phones
iOS SDK
1、Overview
1.1 Target Readers
This document is for iOS developers who want to integrate ZPLAY Ads SDK into their product.
1.2 Development Environment
• Xcode 7.0 and above
• Deploy target: iOS 7.0 and above
2. SDK Download
2.1 Choose third-party SDK
2.2 Download ZPLAY Ads SDK
Please download ZPLAY Ads SDK and add it to your project
DownLoad SDK v2.0.52.3 Download third-party SDK
Please download third-party SDK and add it to your project according to instructions of the third-party platform
3、Development Environment Configuration
3.1 Add ZPLAY Ads SDK
Right click the YUMISample folder,select Add Files to“ YUMISample”.
Click Options and check “Copy items if needed”.
3.2 Configure Script
1. Select the current "YUMISample" project;
2. Select "YUMISample" within this project;
3. Configure YUMISDKConfig script for “Debug” and “Release” in “Configurations” under Info;
3.3 Import framework
1. Select the current "YUMISample" project;
2. Select"YUMISample" under “TARGETS”;
3. Add below system libraries in “Link Binary With Libraries” under “Build Phases” ;
libsqlite3.0.tbd
libxml2.tbd
libc++.tbd
libz1.2.5.tbd
3.4 Configure ATS
Starting from July 2017, Apple App Store will require that all submitted apps to use ATS.You need to switch off the NSAllowsArbitraryLoads switch to enable the ATS verification. After this, all HTTP requests will be shielded.
You can switch on NSAllowsArbitraryLoads if your submitted app does not need the ATS verification. However, you need to state your reason for not using ATS when submitting your game to Apple App Store for approval.
3.4 Permission for iOS 9 and newer versions
Upload apps into App Store. Add below permission in “info.plist”
<key>NSCalendarsUsageDescription</key>
<string>App can't access calender without your permission </string>
<key>NSPhotoLibraryUsageDescription</key>
<string>App can't access album without your permission </string>
4、Integration
4.1 Banner
4.1.1 Import Header File
#import "AdsYuMIView.h"
4.1.2 Set Delegate
<AdsYuMIDelegate>
4.1.3 Declare A Member Variable For Banner
AdsYuMIView * adView;
4.1.4 Initialization
// Initialization interface //@param appkey YUMI ID,you need to create a YUMIID on ZPLAY Ads. //@param adType Size type of banner ads, used to differentiate between ipad and iphone //@param StopRotation If you are using ZPLAY Ads alone, please enable ZPLAY Ads automatic rotation, set the field as “NO”; if you are using ZPLAY Ads in other mediations, to ensure ad performance, please disable ZPLAY Ads rotation and set the field as “YES”. //@param autoAdSize Auto adsize,YES:enable NO:disable //@return Banner object -(id)initWithAppKey:(NSString*)appkey AdViewType:(AdViewYMType)adType StopRotation:(BOOL)stoprotaion isAutoAdSize:(BOOL)autoAdSize ;
Sample:
float h; float w = [UIScreen mainScreen].bounds.size.width; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { float proportion = 90.0f/728.0f; h = w * proportion; }else{ float proportion = 50.0f/320.0f; h = w * proportion; } if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait || [UIDevice currentDevice].orientation == UIDeviceOrientationPortraitUpsideDown){ adView =[[AdsYuMIView alloc]initWithAppKey: @"YUMIID" AdViewType:AdViewYMTypeLargeBanner StopRotation:NO isAutoAdSize:YES]; adView.frame=CGRectMake(0,self.view.frame.size.height-h,0, 0); }else { adView =[[AdsYuMIView alloc]initWithAppKey: @"YUMIID" AdViewType:AdViewYMTypeLargeBanner StopRotation:NO isAutoAdSize:NO]; adView.frame=CGRectMake(([UIScreen mainScreen].bounds.size.width-720)/2, self.view.frame.size.height-90,720,90); } }else { if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait || [UIDevice currentDevice].orientation == UIDeviceOrientationPortraitUpsideDown){ adView =[[AdsYuMIView alloc]initWithAppKey: @"YUMIID" AdViewType: AdViewYMTypeNormalBanner StopRotation:NO isAutoAdSize:YES]; adView.frame=CGRectMake(0,self.view.frame.size.height-h,0, 0); }else { adView =[[AdsYuMIView alloc]initWithAppKey: @"YUMIID" AdViewType: AdViewYMTypeNormalBanner StopRotation:NO isAutoAdSize:NO]; adView.frame=CGRectMake(([UIScreen mainScreen].bounds.size.width-320)/2, self.view.frame.size.height-50,320,50); } } adView.delegate=self; [self.view addSubview:adView];
4.1.5 Hide And Show Banner
//Hide banner adView.hidden = YES; //Show banner adView.hidden = NO;
4.1.6 Banner Size
-
AdViewYMTypeNormalBanner
-
AdViewYMTypeLargeBanner
728x90px, applicable on tablets
4.1.7 Banner Delegate Callbacks
-
viewControllerForPresentingYUMIModalView
Return current view to show banner
This callback must be implemented
-
adsYuMIDidStartAd
Start loading banner
-
adsYuMIDidReceiveAd
Banner impression succeeds
-
adsYuMIDidFailToReceiveAd
Banner display fails
-
adsYuMIClickAd
Banner is clicked
Sample:
// This method shows the current view of banner. If it fails, banner will not be displayed. // return the current banner view - (UIViewController *)viewControllerForPresentingYUMIModalView{ return self; } // Banner starts to request callback - (void)adsYuMIDidStartAd:(AdsYuMIView *)adView{ } // Callback when banner is received successfully - (void)adsYuMIDidReceiveAd:(AdsYuMIView *)adView{ } // Callback when banner fails to be received - (void)adsYuMIDidFailToReceiveAd:(AdsYuMIView *)adView didFailWithError:(NSError *)error{ } // Click callback - (void)adsYuMIClickAd:(AdsYuMIView *)adView{ }
4.2 Interstitial
4.2.1 Import Header File
#import "YuMIInterstitial.h" #import "YuMIInterstitialManager.h"
4.2.2 Set Delegate
<YuMIInterstitialDelegate>
4.2.3 Declare A Member Variable For Interstitial
YuMIInterstitial * inter;
4.2.4 Pre-Caching
// Interstitial initialization // @param appkey YUMI ID,you need to create a YUMI ID on ZPLAY Ads which you can use in the app // @param stopRotation If you are using ZPLAY Ads, please enable ZPLAY Ads automatic rotation, set the field as “NO”. // @return Interstitial object - (YuMIInterstitial *)adYuMIInterstitialByAppKey:(NSString*)appkey isStopRotation:(BOOL)stopRotation;
Sample:
inter= [[YuMIInterstitialManager shareInstance] adYuMIInterstitialByAppKey: @"YUMIID" isStopRotation:NO]; inter.delegate=self;
4.2.5 Show Interstitial
if (inter) { [inter interstitialShow:NO]; }
4.2.6 Interstitial Delegate Callbacks
-
viewControllerForPresentingInterstitialModalView
Return current view to show interstitial
This callback must be implemented
-
YuMIInterstitialDidReceiveAd
Interstitial is shown successfully
-
YuMIInterstitial:didFailToReceiveAdWithError
Interstitial fails to be shown
-
YuMIInterstitialDidDismissScreen
Interstitial is closed
-
adapterDidInterstitialClick
Interstitial is clicked
Sample:
// This method shows the current interstitial view. If it fails, interstitial ads will not be displayed. // Return the view which displays interstitial ads - (UIViewController *)viewControllerForPresentingInterstitialModalView { return self; } // Interstitial is shown successfully //@param ad Return an interstitial instantiation - (void)YuMIInterstitialDidReceiveAd:(YuMIInterstitial *)ad { } // Interstitial ads loading failed //@param ad Return an interstitial instantiation // @param error Return error message - (void)YuMIInterstitial:(YuMIInterstitial *)ad didFailToReceiveAdWithError:(NSError *)error { } // Interstiail is closed // @param ad Return an interstitial instantiation - (void)YuMIInterstitialDidDismissScreen:(YuMIInterstitial *)ad {} // Interstitial click callback - (void)adapterDidInterstitialClick{}
4.3 Rewarded video
4.3.1 Import Header File
#import <YMVideo/YMVideo.h>
4.3.2 Set Delegate
<YMVideoDelegate>
4.3.3 Initialize Rewarded Video
// Video initialization //@param appkey YUMIID, you need to create a YUMI ID on ZPLAY Ads //@param delegate Delegate //@return Video object +(id)startWithYuMIId:(NSString*)yumiId delegate:(id<YMVideoDelegate>) delegate;
Sample:
[YMVideoManager startWithYuMIId: @"YUMIID" delegate:self];
4.3.4 Check If There Is An Available Rewarded Video To Be Played
// If pre-cashing is complete // YES: complete // NO: incomplete [[YMVideoManager sharedVideoManager] isReadVideo]
4.3.5 Show Rewarded Video
// When there are available video ads at the Method of [[YMVideoManager sharedVideoManager] isReadVideo], call to play video [[YMVideoManager sharedVideoManager] playVideo];
4.3.6 Rewarded Video Delegate Callbacks
-
viewControllerVideoModalView
Return current view to show video
This callback must be implemented
-
didCompleteVideo
Video is closed
-
rewardsVideo
User gets rewards
Sample:
// This method shows the current interstitial view. If it fails, interstitial ads will not be displayed. // Return the view which displays current video - (UIViewController *)viewControllerVideoModalView { return [[[UIApplication sharedApplication] keyWindow] rootViewController]; } // Video closed //@param _adapter Platform adapter //@param view Platform view - (void)didCompleteVideo{ } // Platform video reward //@param _adapter //@param view -(void)rewardsVideo{ }
4.4 Splash
4.4.1 Import Header File
#import "YMANFullScreen.h" #import "YMANFullScreenDelegate.h"
4.4.2 Initialization
// Initialize splash //@param appkey YUMI ID, you need to create a YUMI ID on ZPLAY Ads //@param delegate Splash delegate // @param window Window object of current app // @return -(void)initWithAppKey:(NSString*)appkey delegate:(id)delegate win-dow:(UIWindow *)window;
Sample:
[[YMANFullScreen shareInstance] initWithAppKey:@"玉米ID" delegate:self window:self.window];
4.4.3 Delegate Callbacks
-
viewControllerForPresentingYMANFullScreenModalView
Return current view to show splash
This callback must be implemented
-
YMANFullScreenAdiPhoneImage
Set default launch image
-
YMANFullScreenWillDidStart
Start loading splash
-
YMANFullScreenLoadFail
Splash loading fails
-
YMANFullScreenLoadSuccess
Splash loading succeeds
-
YMANFullScreenClickCloseBtn
Splash ads closed
-
YMANFullScreenStartWebBrower
Open built-in browser
-
YMANFullScreenWebBrowerWillDidClose
Close built-in browser
Sample:
- (UIViewController *)viewControllerForPresentingYMANFullScreenModalView{ return self.window.rootViewController; } // Set default launch image // @return launch image name - (NSString *)YMANFullScreenAdiPhoneImage{ if([[UIDevice currentDevice]userInterfaceIdiom] == UIUserInterfaceIdiomPad){ return @"Default-Portrait"; } else{ return @"Default"; } } // Start loading splash - (void)YMANFullScreenWillDidStart{ } // Splash loading failes - (void)YMANFullScreenLoadFail:(NSError *)error{ } // Splash loading succeeds - (void)YMANFullScreenLoadSuccess{ } // Splash ads closed - (void)YMANFullScreenClickCloseBtn{ } // Open built-in browser - (void)YMANFullScreenStartWebBrower{ } // Close built-in browser - (void)YMANFullScreenWebBrowerWillDidClose{ }
5、Advanced Features
5.1 Test Mode
ZPLAY Ads SDK provides a test mode to test your 3rd-party Integrations.
1、Call method to open test page:
#import <YuMIDebugCenter/YuMIDebugCenter.h> [[YuMIDebugCenter shareInstance] startDebugging:self];
2、ZPLAY Ads SDK will get configuration and show third-party platform list
3、Choose a platform
4、Click Request to start requesting ads, click Show to show ads
5、The platform has been successfully integrated after impression succeeds
6、Comment out the test code before app launch
Note: If the adapter is not added to the platform, it will prompt: interstitial of adapter not integration
5.2 Banner Ads Automatically Adapt To Screen Size
- Non auto adaptaion
- auto adaptaion
When you set banner ad container, you can use isMatchWindowWidth, a parameter of boolean type provided by ZPLAY Ads SDK. This parameter indicates if banner width has populated full screen. When it's YES, banner width equals the screen width.