Interstitial Integration For iOS english - unigeniee/Geniee-iOS-SDK GitHub Wiki
Interstitial ads are full-screen advertising that cover the interface of the host app. The ads are typically displayed at natural transition points in the flow of an app, such as start-up the application, or between activities or during the pause between levels in a game.
To Implement the interstitial ads, you need to install the Geniee SDK to the project. Please follow the Start Guide for the process. Start Guide
iOS interstitial ad delivery use the following classes;
- GNInterstitial Asynchronous acquisition interstitial Ads, Class for Display
- GNInterstitialDelegate Interstitial cycle event processing protocol
-
Add
GNAdSDK.framework
to project. Start Guide -
Import
GNInterstitial.h
.#import <GNAdSDK/GNInterstitial.h>
-
Apply
GNInterstitialDelegate
protocol.@interface MyViewController : UIViewController<GNInterstitialDelegate> { }
-
Declare the variable of
GNInterstitial
.GNInterstitial *_interstitial;
-
Initialise the instance of
GNInterstitial
._interstitial = [[GNInterstitial alloc] initWithID:@"YOUR_SSP_APP_ID"];
YOUR_SSP_APP_ID sets management ID of AdsZone in Geniee.
-
Set delegate of
GNInterstitial
.
Interstitial ads processing cycle event, it will be notified via the delegate.
You sets instance variables employingGNInterstitialDelegate
protocol._interstitial.delegate = self;
-
Set rootViewController of
GNInterstitial
._interstitial.rootViewController = self;
-
When you release instance of
GNInterstitial
, set delegate tonil
.- (void)dealloc { _interstitial.delegate = nil; }
-
Example Implementation of MyViewController:
// MyViewController.h #import <GNAdSDK/GNInterstitial.h> @interface MyViewController : UIViewController<GNInterstitialDelegate> { GNInterstitial *_interstitial; } @end
// MyViewController.m @implementation MyViewController - (void)viewDidLoad { [super viewDidLoad]; _interstitial = [[GNInterstitial alloc] initWithID:@"YOUR_SSP_APP_ID"]; _interstitial.delegate = self; _interstitial.rootViewController = self; } - (void)dealloc { _interstitial.delegate = nil; } @end
AdSize of 300x250.
Load interstitial ad display tags from Ad server.
GNInterstitial
is preloaded before display,
Please set the appropriate time to prepare the completion of Ad
-
If loading is success, it will be notified by
onReceiveSetting
callback function of delegate. -
If loading is failed, it will be notified by
onFailedToReceiveSetting
callback function of delegate.[_interstitial load];
Please check the display interstitial ads before delivering.
-
Example explains how to display interstitial at the time of the screen transition.
- (void)showEventFunc { if (_interstitial.isReady) { [_interstitial show:self]; } }
- Parameter
self
:Variable of the current screen ViewController
- Parameter
- From the management screen, set the background transparency of the advertisement.
- If it is not working please add following code before ad display.
UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController; rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext; [_interstitial show:self];
To update interstitial ads, you need to display after re-loading ad.
-
CallBack function implementation of
GNInterstitialDelegate
, it will receive advertisement processing cycle events.@protocol GNInterstitialDelegate <NSObject> @required /// It will be sent when reading of advertising data has been completed. - (void)onReceiveSetting; @optional /// It will be sent to when failed to read ad in the cause such as a network error. - (void)onFailedToReceiveSetting; /// It will be sent immediately after interstitial ad screen is closed. - (void)onClose; /// From management screen, buttons that were installed in the advertising screen will be tapped. /// It will be sent immediately after the interstitial ad screen is closed. /// Number of buttons have been tapped, you will be notified by `nButtonIndex` parameters. - (void)onButtonClick:(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/GNInterstitial.h>
-
Set file name in the "Build Settings" to 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」.