Release Notes: (1.2.2)
  • Updated to Vungle Android SDK 3.3.1.
  • Updated to Vungle iOS SDK 3.1.2.

Integration Guide - Vungle Ad Plugin

Platforms: Android & iOS
Plugin version: 1.2.2
Vungle iOS SDK version: 3.1.2
Vungle Android SDK version: 3.3.1

Generally you don't have to dive into the documentation from Vungle, simply follow a few steps below to get the plugin integrated in your App in minutes:

[1] Import the VungleAd[Android|IOS|Universal].unitypackage file to your unity project;

[2] Follow the instructions below to configure the plugin.

· >>> For Android platform, click on the menu item of Unity top menu bar: NeatPlug -> VungleAd -> Patch Android Configuration. This is for generating a valid AndroidManifest.xml or patching the existing file with VungleAd support.


· >>> For iOS platform, click on the menu item of Unity top menu bar: NeatPlug -> VungleAd -> Patch iOS Configuration. This is for automatically adding iOS SDK frameworks, libraries or patching the Info.plist file (if needed) as long as the Xcode project is generated by Unity.

[3] Find VungleAdAgent Prefab and VungleAdListener Prefab in Assets/Plugins/NeatPlug/Ads/VungleAd/Prefabs/, open the first scene of your game, drag & drop those two prefabs into the scene.

[4] Okay, the integration is done here. Now set up your Ad by filling in a few properties of the VungleAdAgent gameObject which you just dropped in the Hierarchy window. To do this, simply select that gameObject, and look at its properties in the Inspector window, you need to fill in:

   · App ID [Android|IOS] - Your Vungle App ID for Android or IOS.

   · Debug Mode - Check this if you want to see verbose debug info in the log.

   · Ad Orientation - Select the Ad orientation [MatchVideo, AutoRotate].

   · Sound Enabled - Check this if you want to enable the sound while playing an Ad.

[5] Okay, the integration is done here, to use the plugin, see below:

  Call the following functions to initialize and request an Ad:

   · VungleAd.Instance().Init(...) - Required if you don't apply "App IDs" property value for VungleAdAgent.

   · VungleAd.Instance().PlayAd() - Play a cached interstitial video Ad.

   · VungleAd.Instance().PlayIncentivizedAd(...) - Play a cached incentivized video Ad.

   · VungleAd.Instance().IsAdCached() - Check if there're any cached Ad to play.

  There are other useful public methods that VungleAd provides, to use them, simply call VungleAd.Instance().methodName().
Show All   
public void Init(string appIdAndroid, string appIdIOS, VungleAdSettings settings)
/**
 * Initialization, set the Vungle App Id.
 * 
 * @param appIdAndroid
 *            string - Your Android App ID.
 * 
 * @param appIdIOS
 *            string - Your IOS App ID.
 * 
 * @param settings
 *            VungleAdSettings - The settings for the Ad. Available properties are:                              
 *
 *                               #1. soundEnabled: bool: set if enable sound.
 *
 *                               #2. orientation: VungleAdSettings: set the Ad 
 *                                   orientation{MatchVideo, AutoRotate} 
 *
 *                               #3. debugMode: bool: set if enable debug logging.
 * 	
 */
public void Init(string appIdAndroid, string appIdIOS, VungleAdSettings settings)
public bool PlayAd()
/**
 * Play an Ad.    
 */
public bool PlayAd()
public void PlayAd(VungleAdSettings settings)
/**
 * Play an Ad with override config.
 *
 * @param settings
 *            VungleAdSettings - The settings for the Ad. Available properties are:               
 *
 *                               #1. soundEnabled: bool: set if enable sound.
 *
 *                               #2. orientation: VungleAdSettings: set the Ad 
 *                                   orientation{MatchVideo, AutoRotate}          
 */
public void PlayAd(VungleAdSettings settings)
public void PlayIncentivizedAd(string userId)
/**
 * Play an Incentivized Ad. 
 * 
 * @param userId
 *         string - The identifier of the user.
 */
public void PlayIncentivizedAd(string userId)
public void PlayIncentivizedAd(string userId, VungleAdSettings settings)
/**
 * Play an Incentivized Ad. 
 * 
 * @param userId
 *         string - The identifier of the user.	
 * 
 * @param settings
 *            VungleAdSettings - The settings for the Ad. Available properties are:                         
 *
 *                               #1. soundEnabled: bool: set if enable sound.
 *
 *                               #2. orientation: VungleAdSettings: set the Ad 
 *                                   orientation{MatchVideo, AutoRotate}   
 */
public void PlayIncentivizedAd(string userId, VungleAdSettings settings)
public void IsAdCached()
/**
 * Check if there is a cached Ad available.
 * 
 * @return bool - If the cached Ad is available.
 */
public void IsAdCached()

[6] For advanced users who need to handle Ad events, read this:

  Follow the instructions to handle Ad events:

  · Select the dropped VungleAdListener gameObject, locate the VungleAdListener.cs script, open it and make some modifications.

  These callbacks are exposed in the script, you can supply your own implementations in them.
Show All   
void OnAdCached() { ... }
/**
 * Fired when an Ad is successfully cached.
 */
void OnAdCached()
{
    /// Your code here...   
}
void OnFailedToCacheAd(string err) { ... }
/**
 * Fired when an Ad failed to be cached.
 * 
 * @param err
 *         string - The error message.
 */
void OnFailedToCacheAd(string err)
{
    /// Your code here...   
}
void OnAdStarted() { ... }
/**
 * Fired when a video Ad play is started.
 */
void OnAdStarted()
{
    /// Your code here...   
}
void OnAdEnded() { ... }
/**
 * Fired when a video Ad play is ended.	
 */
void OnAdEnded()
{
    /// Your code here...
}
void OnAdViewed(float watchedSeconds, float videoDurationSeconds, bool isCompletedView) { ... }
/**
 * Fired when a video Ad is viewed.
 * 
 * This is the place where you can issue reward to the user for watching the Ad, 
 * if the user has viewed the full video.
 *
 * @param  watchedSeconds
 *               float - The time of video watched. (In seconds)
 * 
 * @param videoDurationSeconds
 *               float - The duration of the video. (In seconds)
 * 
 * @param isCompletedView
 *               bool - If the user has viewed the full video.
 *                      
 */
void OnAdViewed(float watchedSeconds, float videoDurationSeconds, bool isCompletedView)
{
    /// Your code here...   
}

[7] Build your App now. To compile for iOS platform, you need to have Xcode installed.

[8] Test and verify if the Ad can show up as expected, don't forget to test if the Ad is clickable and if the Ad window can be opened. It is suggested that you should turn on Test Mode (Test Mode can be set in Vungle App Settings at Vungle website.) Also it would be helpful for you to address issues if you take a look at the logcat output (Android) or xcode debug console (iOS) to find the debug / error / warning messages.

[EOF] Should you have any questions or encounter any problems while integrating the plugin, please do not hesitate to shoot us an email at support@neatplug.com, we will be more than happy to help you. Thanks for choosing NeatPlug solutions!