Interstitial Integration For iOS English - Hiroaki-Shinoda/Geniee-iOS-SDK GitHub Wiki

Implementation of Interstitial Ads

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.

Preparation

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

Class and protocol

iOS interstitial ad delivery use the following classes;

  • GNInterstitial Asynchronous acquisition interstitial Ads, Class for Display
  • GNInterstitialDelegate Interstitial cycle event processing protocol

Set Up Interstitial Ads

  1. Add GNAdSDK.framework to project. Start Guide

  2. Import GNInterstitial.h.

    #import <GNAdSDK/GNInterstitial.h>
  3. Apply GNInterstitialDelegate protocol.

    @interface MyViewController : UIViewController<GNInterstitialDelegate>
    {
    }
  4. Declare the variable of GNInterstitial.

    GNInterstitial *_interstitial;
  5. Initialise the instance of GNInterstitial.

    _interstitial = [[GNInterstitial alloc] initWithID:@"YOUR_SSP_APP_ID"];

YOUR_SSP_APP_ID sets management ID of AdsZone in Geniee.

  1. Set delegate of GNInterstitial.
    Interstitial ads processing cycle event, it will be notified via the delegate.
    You sets instance variables employing GNInterstitialDelegate protocol.

    _interstitial.delegate = self;
  2. Set rootViewController of GNInterstitial.

    _interstitial.rootViewController = self;
  3. When you release instance of GNInterstitial, set delegate to nil.

    - (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

Size of Interstitial Ads

AdSize of 300x250.

Load Interstitial Ads

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];

Display Interstitial Ads

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

Background transparency of interstitial ads

  • 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];

Update interstitial ads

To update interstitial ads, you need to display after re-loading ad.

GNInterstitialDelegate Protocol

  • 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

Using iOS SDK from Swift

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」. image

⚠️ **GitHub.com Fallback** ⚠️