Video Ads Integration For iOS english - unigeniee/Geniee-iOS-SDK GitHub Wiki
VIDEO ads are displayed at natural transition points in the flow of an app like interstitial ads, such as start-up the application, or between activities or during the pause between levels in a game.
To Implement the Video ads, you need to install the Geniee SDK to the project. Please follow the Start Guide for the process. Start Guide
iOS video ad delivery use this following class.
- GNAdVideo Asynchronous retrieve the video ads and the class for display
- GNAdVideoDelegate Interstitial cycle event processing protocol
-
Add
GNAdSDK.framework
to project. Start Guide -
Import
GNAdVideo.h
.#import <GNAdSDK/GNAdVideo.h>
-
Apply
GNAdVideoDelegate
protocol.@interface MyViewController : UIViewController<GNAdVideoDelegate> { }
-
Declare the variable of
GNAdVideo
.GNAdVideo *_videoAd;
-
Initialise the instance of
GNAdVideo
._videoAd = [[GNAdVideo alloc] initWithID:@"YOUR_SSP_APP_ID_FOR_VIDEO"];
YOUR_SSP_APP_ID sets management ID of AdsZone in Geniee.
- Set the delegate of
GNAdVideo
.
- Video ad processing cycle events will be notified via delegate.
- Set
GNAdVideoDelegate
the instance variable adopted protocol._videoAd.delegate = self;
-
Set the root ViewController of
GNAdVideo
._videoAd.rootViewController = self;
-
When you release the instance of
GNAdVideo
set the delegate tonil
.- (void)dealloc { _videoAd.delegate = nil; }
-
Example Implementation of MyViewController:
// MyViewController.h #import <GNAdSDK/GNAdVideo.h> @interface MyViewController : UIViewController<GNAdVideoDelegate> { GNAdVideo *_videoAd; } @end
// MyViewController.m @implementation MyViewController - (void)viewDidLoad { [super viewDidLoad]; _videoAd = [[GNAdVideo alloc] initWithID:@"YOUR_SSP_APP_ID_FOR_VIDEO"]; _videoAd.delegate = self; _videoAd.rootViewController = self; } - (void)dealloc { _videoAd.delegate = nil; } @end
Load video ads display for the tag from Ad server.
GNAdVideo is preloaded before display, please set the appropriate time to prepare for completion of ads.
-
If it successes to load, it will be notified by
onGNAdVideoReceiveSetting
callback function of delegate. -
If it fails to load, it will be notified by
onGNAdVideoFailedToReceiveSetting
callback function of delegate.[_videoAd load];
Please check whether video ads is ready to be displayed before displaying period.
-
This example explains how to display video ads at the time of the screen transition.
- (void)showEventFunc { if ([_videoAd isReady]) { [_videoAd show:self]; } }
- Parameter
self
:Variable of ViewController of the current screen
- Parameter
To update video ads, you need to display to re-load ads.
-
When there is no stock or acquisition failure on the video ads, you can display alternative interstitial ads.
-
Set the alternative interstitial ads and set management ID of interstitial AdZone.
[_videoAd setAlternativeInterstitialAppID:@"YOUR_SSP_APP_ID_FOR_INTERSTITIAL"];
-
Implement CallBack function of
GNAdVideoDelegate
and you will receive advertisement processing cycle events.@protocol GNAdVideoDelegate <NSObject> @required /// It will be sent when the reading of advertising data has been completed. - (void)onGNAdVideoReceiveSetting; @optional /// It will be sent to when that failed to read Ad in the cause such as a network error. - (void)onGNAdVideoFailedToReceiveSetting; /// Video ad screen will be sent immediately after that is closed. - (void)onGNAdVideoClose; /// From the management screen, buttons were installed in advertising screen will be tapped. /// Alternate interstitial advertising screen will be sent immediately after that is closed. /// Number of buttons have been tapped, you will be notified by `nButtonIndex` parameters. - (void)onGNAdVideoButtonClick:(NSUInteger)nButtonIndex; @end
You can use iOS SDK (Objective-C) class from the Swift, by writing the import statement of header files in a file called Objective-C bridging header.
-
Add
<ProjectName>-Bridging-Header.h
file to project. -
Write Import-Sentence in
<ProjectName>-Bridging-Header.h
file.#import <GNAdSDK/GNAdVideo.h>
-
Set file name in the "Build Settings" in project.
In settings, please select a target in the project root and set<ProjectName>-Bridging-Header.h
to 「Build Settings」->「Swift Compiler - Code Generation」->「Objective-C bridging header」.