VMAX
 
 
 
 
Show Sidebar

Cocos2d-x SDK for iOS

For Cocos2d-x version 3 and above.

Overview

VMAXCocosAdSDK is a Cocos2d-x wrapper around the VMAX Native iOS SDK with integration using C++.

Mediation Partners

Interstitial

  • AdColony
  • AdMob
  • Chartboost
  • Facebook Audience Network
  • Flurry
  • Millennial Media
  • Vungle

Interstitial Video

  • Adcolony
  • Chartboost
  • Vungle

Rewarded Video

  • AdColony
  • Chartboost
  • Pokkt
  • UnityAds
  • Vungle

Native Icon

  • Facebook Audience Network (Native)
  • Inmobi (Native)

Integrating the SDK

Prerequisites

  • Cocos Studio v3.x
  • Xcode 7.2 or above
  • iOS SDK 9.0 or above

Basic Setup

  1. Add the Native VMAXCocosAdSDK consisting of the header files & the libVMAXCocosAdSDK.a lib file to your iOS Xcode project generated by Cocos Studio.
  2. Add the Native VMAX iOS SDK (dependent SDK for VMAXCocosAdSDK) consisting of the header files, resources bundle & the libVMaxAdSDK.a lib file to your Xcode project.
  3. Import the VMAXCocosAd header in the Cocos2D Scene that you wish to integrate VMAXCocosAdSDK with as follows:
  4. Add “–ObjC” flag in “Other Linker Flags” in your Xcode project’s ‘Build Settings’

Integration

  1. Extend the Scene class of your game with VMaxSDK::VMAXCocosAdListener and implement all the methods in that abstract class.
  2. For Interstitial and Rewarded Video ads declare the member variable for holding the ad of type VMAXCocosAd as follows:
  3. For Native Icon Ad declare the member variable of type VMAXCocosNativeIcon
  4. After instantiation, for Interstitial and Rewarded Video Ads; create an ad request.

The Ad instantiation procedure for different types of ads is described in detail in the sections below.

If you want to have more control over ad caching and display, use the CacheAd() api to cache the ad to memory.

After successful caching of the ad you may display the ad using the ShowAd() api. If ShowAd() is called without caching the ad or on a cache failed scenario then it has no effect.

To display an ad without caching, call the LoadAd() api:

Integrating Mediation Partners

  1. For the Mediation partners that you wish to support, add the corresponding Adapter files to the Xcode project
  2. Enable ARC for the Adapters. While the Cocos Studio generated Xcode project has ARC disabled, the mediation adapters require ARC to function. To enable ARC, set the flag ‘-fobjc-arc’ for the mediation adapters in ‘Build Phases > Compile Sources’ section of your Xcode project’s Target (see screenshot below)
Mediation partner adapters - Enable ARC

Mediation partner adapters – Enable ARC

For more information, read on how to integrate mediation partners in iOS.

Instantiating Interstitial Ads

Use the following factory method to create an Interstitial ad.

Code invocation is as follows assuming that the current object is the listener which implements the VMaxSDK::VMAXCocosAdListener interface

Instantiating Rewarded Video Ads

  1. Create Rewarded Video Ad instance:
    Use the following factory method to create the Rewarded Video ad.

    Code invocation is as follows assuming that the current object is the listener which implements VMaxSDK::VMAXCocosAdListener interface

  2. Setup the Wallet Element:
    Get the Wallet Element for your currency type and configure it.

  3. Setup the Rewarded Video:
    Create an instance of Rewarded Video, configure it with the Wallet Element created in step #2 and set the rewarded video to the VMAXCocosAd instance created in step #1 above

Instantiating Native Icon Ads

Note: Currently, AdMob Native Express ads are not supported for native icon format.

Use the following factory method to create the Rewarded Video ad.

Code invocation is as follows assuming that the current object is the listener which implements VMaxSDK::VMAXCocosNativeIconListener interface

Request an icon ad using the CacheAd() api:

After the icon ad is cached, it can be displayed by calling ShowAdAtLocation() api:

Code invocation is as follows where parentNode is the Node at which the Native icon has to be placed:

Note: LoadAd() api is not applicable for Native Icon Ad.

You can then proceed to test your integration.