-
Notifications
You must be signed in to change notification settings - Fork 0
2.2 Aotter Ad Video 影音廣告 (deprecated)
superwave edited this page Aug 14, 2019
·
1 revision
- create adVideo object
-(void)initialVideoAd{
self.videoAd = [ATAdVideo alloc] init];
//initial ad with place and categories(optional)
[self.videoAd ATinitialWithPlace:@"<myAdPlace>"]:
//set viewControllerForShowing to current ViewController
[self.videoAd ATsetPresetingViewController:self];
//set delegate (optional)
self.videoAd.delegate = self;
//fetch Ad data from API
[self.videoAd ATfetchAd:^(NSDictionary *adData) {
dispatch_async(dispatch_get_main_queue(),^{
//start to load playerItem. when finsished will receive delegate `ATAdVideoReadyToPlay:` and self.videoAd.isReadyToPlay == YES
});
}];
}
-(void)ATAdVideoReadyToPlay:(ATAdVideo *)ad{
//rendering your VideoAd View or play the ad
}
- render adNatvie UI object
//set tracking view
[self.videoAd ATsetTrackingView:self.myAdView];
//set tracking Action button
[self.videoAd ATsetTrackingActionButton:self.myButton];
//set video conatiner view
[self.videoAd ATsetVideoContainer:self.myVideoContainerView];
//render adData
NSDictionary adData = self.AdData;
if(adData){
//if fetchAd success, adData contains metadata for rendering
}
-
play and pause videoAd.
devlopers have to handling the play/pause event by their own. for UITableView use
tableView: willDisplayCell:
andtableView: didEndDisplayingCell:
.//play [self.videoAd ATplayVideo]; //pause [self.videoAd ATpauseVideo];
Variable | Type | description |
---|---|---|
adType | String | |
uuid | String | |
title | String | |
text | String | |
sponser | String | |
callToAction | String | for action button title |
advertiserName | String | |
img_icon | String | 82x82 |
img_icon_hd | String | 300x300 |
img_main | String | 1200x627 |
- other delegate
@protocol ATAdVideoDelegate <NSObject>
-(void)ATAdVideoReadyToPlay:(ATAdVideo *)ad;;
-(void)ATAdVideoDidReceiveAd:(ATAdVideo *)ad;
-(void)ATAdVideoFetchNoAd:(ATAdVideo *)ad;
-(void)ATAdVideoDidDismissFullScreenMode:(ATAdVideo *)ad;
@end
- show full screen player without inline native video ad
//set transition style for fullscreen player
[self.videoAd ATsetFullScreenPlayerTransition:UIModalTransitionStyleCrossDissolve]
//set close button hide time (optional, default = 0)
[self.videoAd ATsetCloseButtonHideTime:3.0f];
//show the fullscreen player
[self.videoAd ATshowFullScreenPlayer];
-
fullscreen orientation
ATAdVideo fullscreen player support responsive design. if your project is using
UIInterfaceOrientationMask
to handle orientation changing, detectATAdVideoFullScreenViewController
for presented.- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window{ id presentedViewController = [window.rootViewController presentedViewController]; NSString *className = presentedViewController ? NSStringFromClass([presentedViewController class]) : nil; ATAdVideoFullScreenViewController *ATFullScreenVC = (ATAdVideoFullScreenViewController *)presentedViewController; if (window && [className isEqualToString:@"ATAdVideoFullScreenViewController"] && ATFullScreenVC.isPresented){ return UIInterfaceOrientationMaskAll; } else { return UIInterfaceOrientationMaskPortrait; } }
-
remove and release data
//remove and release data
[self.videoAd ATreleaseAd];