Release Notes: (1.3.5)
  • Updated to MMedia Android SDK - v5.3.0.
  • Updated to MMedia iOS SDK - v5.4.1.

Integration Guide - MillennialMedia Ad Plugin

Platforms: Android, iOS
Plugin version: 1.3.5
MMedia iOS SDK version: 5.4.1
MMedia Android SDK version: 5.3.0
Supported Unity3d version: 3.5.x, 4.x, 5.x

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

[1] Import the MmediaAd[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 -> MmediaAd -> Patch AndroidManifest. This is for generating a valid AndroidManifest.xml or patching the existing file with MmediaAd support.


· >>> For iOS platform, click on the menu item of Unity top menu bar: NeatPlug -> MmediaAd -> 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 MmediaAdAgent Prefab and MmediaAdListener Prefab in Assets/Plugins/NeatPlug/Ads/MmediaAd/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 MmediaAdAgent 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:

   · Show Device Id In Log - Check this if you want to see the Mmedia Device ID in log.

   · Banner Ap Id [Android|IOS] - Mmedia banner APID for Android or IOS.

   · Rectangle Banner Ap Id [Android|IOS] - Mmedia rectangle banner APID for Android or IOS.

   · Interstitial Ap Id [Android|IOS] - Mmedia interstitial APID for Android or IOS.

   · Auto Load Banner Ad - Check this if you want to load banner Ad automatically.

   · Auto Load Banner Ad In Scenes - In which scenes(levels) you want the banner Ad to be auto-loaded. (Set size to zero for all scenes)

   · Auto Load Banner Ad Type - Select the auto-loaded Ad type.

   · Auto Load Banner Ad Layout - Select the auto-loaded Ad layout.

With Auto Load Banner Ad checked, Ad will show up on device after you compile and run then. Basic users can jump straight to step [7] now.

[5] For advanced users who want to take full control of Ads, e.g. close an Ad after an In-App purchase is made, or preload an Ad for later display etc, see below:

  Call the following functions to initialize and request an Ad:

   · MmediaAd.Instance().Init(...) - Required if you don't apply "Ap Ids" property value for MmediaAdAgent.

   · MmediaAd.Instance().LoadBannerAd(...) - Request a Banner Ad.

   · MmediaAd.Instance().LoadInterstitialAd(...) - Request an Interstitial Ad.

  There are other useful public methods that MmediaAd provides, to use them, simply call MmediaAd.Instance().methodName().
Show All   
public void Init(string bannerApId, string rectangleBannerApId, string interstitialApId)                
/**
 * Initialization.	
 * Set the AP IDs (Ad Placement ID, can be obtained from Millennial Media Publisher Site).
 *
 * NOTE: This function only needs to be called if you don't configure your AP IDs 
 * in MmediaAdAgent gameObject properties.  
 *
 * @param bannerApId
 *            string - Your top banner AP ID
 *
 * @param rectangleBannerApId
 *            string - Your rectangle banner AP ID
 *
 * @param interstitialBannerApId
 *            string - Your interstitial banner AP ID
 *
 */
public void Init(string bannerApId, string rectangleBannerApId, string interstitialApId)
public void LoadBannerAd(MmediaAd.BannerAdType adType, MmediaAd.AdLayout layout, int offsetX = 0, ... )
/**
 * Load a Banner Ad.
 * 
 * @param adType
 *           BannerAdType - Type of the Ad.
 * 
 * @param layout
 *           AdLayout - In which layout the Ad should display.
 * 
 * @param offsetX
 *           int - The horizontal offset of the Ad, if the layout is set to left, 
 *                 the offset is from the left edge of screen to the left edge of 
 *                 the Ad; if the layout is set to right, the offset is from the 
 *                 right edge of screen to the right edge of the Ad. 
 *                 The offset is in pixels.
 * 
 * @param offsetY
 *           int - The vertical offset of the Ad, if the layout is set to top, 
 *                 the offset is from the top edge of screen to the top edge of 
 *                 the Ad; if the layout is set to bottom, the offset is from the 
 *                 bottom edge of screen to the bottom edge of the Ad. 
 *                 The offset is in pixels.                 
 * 
 * @param hide
 *           bool - whether the ad should keep being invisible after loaded,
 *                  true for making the ad hidden, false for showing the 
 *                  ad immediately. if the parameter is set to true, then 
 *                  you need to programmatically display the ad by calling 
 *                  ShowBannerAd() after you get notified with event
 *                  OnReceiveAd from AdmobAdListener.
 *	
 */
public void LoadBannerAd(MmediaAd.BannerAdType adType, MmediaAd.AdLayout layout, 
                                         int offsetX = 0, int offsetY = 0
                                         boolhide = false)
public void LoadBannerAd(MmediaAd.BannerAdType adType, int top, int left, bool hide = false)
/**
 * Load a Banner Ad and place it at specified absolute position.
 * 
 * Please note that the Ad won't display if the top or left applied
 * makes the Ad display area outside the screen.
 * 
 * @param adType
 *           BannerAdType - the type of Ad.
 *
 * @param top
 *           int - the top margin (in pixels) for placing Ad in absolute position.
 *
 * @param left
 *           int - the left margin (in pixels) for placing Ad in absolute position. 
 *
 * @param hide (Optional, default false)
 *           bool - whether the ad should keep being invisible after loaded,
 *                  true for making the ad hidden, false for showing the 
 *                  ad immediately. if the parameter is set to true, then 
 *                  you need to programmatically display the ad by calling 
 *                  ShowBannerAd() after you get notified with event
 *                  OnReceiveAd from MmediaAdListener.
 */
public void LoadBannerAd(MmediaAd.BannerAdType adType, int top, int left, bool hide = false)
public void ShowBannerAd()
/**
 * Show the Banner Ad.
 *
 * This sets the banner ad to be visible.
 */
public void ShowBannerAd()
public void HideBannerAd()
/**
 * Hide the Banner Ad.
 *
 * This sets the banner ad to be invisible again.
 */
public void HideBannerAd()
public void RefreshBannerAd()
/**
 * Refresh the Banner Ad.
 *
 * This initiates a new ad request to plugin.
 */
public void RefreshBannerAd()
public void DestroyBannerAd()
/**
 * Destroy the Banner Ad.
 */
public void DestroyBannerAd()
public void LoadInterstitialAd(bool hide = false)
/**
 * Load an Interstitial Ad.
 *
 * @param hide (Optional, default false)
 *           bool - whether the ad should keep being invisible after loaded,
 *                  true for making the ad hidden, false for showing the 
 *                  ad immediately. if the parameter is set to true, then 
 *                  you need to programmatically display the ad by calling 
 *                  ShowInterstitialAd() after you get notified with event
 *                  OnReceiveAd from MmediaAdListener.
 */
public void LoadInterstitialAd(bool hide = false)
public void ShowInterstitialAd()
/**
 * Show the Interstitial Ad.
 *
 * This sets the Interstitial ad to be visible.
 */
public void ShowInterstitialAd()
public void LoadPrestitialAd(bool hide = false)
/**
 * Load a Prestitial Ad.
 *
 * @param hide (Optional, default false)
 *           bool - whether the ad should keep being invisible after loaded,
 *                  true for making the ad hidden, false for showing the 
 *                  ad immediately. if the parameter is set to true, then 
 *                  you need to programmatically display the ad by calling 
 *                  ShowPrestitialAd() after you get notified with event
 *                  OnReceiveAd from MmediaAdListener.
 */
public void LoadPrestitialAd(bool hide = false)
public void ShowPrestitialAd()
/**
 * Show the Prestitial Ad.
 *
 * This sets the Prestitial ad to be visible.
 */
public void ShowPrestitialAd()
public void SetDisableBannerAutoRefresh(bool disabled)
/**
 * Set if disable banner auto-refresh.
 * 
 * @param disabled
 *          bool - true for disabling auto-refresh, 
 *                 false for enabling auto-refresh.
 *	
 */
public void SetDisableBannerAutoRefresh(bool disabled)
public void SetUseCustomBannerRefreshInterval(bool shouldUse)
/**
 * Set if use custom banner refresh interval.
 * 
 * @param shouldUse
 *             bool - true for using custom interval,
 *                    false for not using.
 *	
 */
public void SetUseCustomBannerRefreshInterval(bool shouldUse)
public void SetCustomBannerRefreshInterval(int interval)
/**
 * Set custom banner refresh interval.
 * 
 * @param interval
 *            int - custom banner refresh interval value.
 *	
 */
public void SetCustomBannerRefreshInterval(int interval)

[6] For advanced users who need to handle Ad events, e.g. reposition the game HUD bar as long as an Ad is displayed. Read this:

  Follow the instructions to handle Ad events:

  · Select the dropped MmediaAdListener gameObject, locate the MmediaAdListener.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 OnAdShown() { ... }
/**
 * Fired when the banner Ad is shown.
 */
void OnAdShown()
{
    /// Your code here...   
}
void OnAdHidden() { ... }
/**
 * Fired when the banner Ad is hidden.
 */
void OnAdHidden()
{
    /// Your code here...   
}
void OnReceiveAd() { ... }
/**
 * Fired when a banner Ad is received successfully.
 */
void OnReceiveAd()
{
    /// Your code here...
}
void OnFailedToReceiveAd(string err) { ... }
/**
 * Fired when a banner Ad fails to be received.
 *
 * @param err
 *          string - The error string
 */
void OnFailedToReceiveAd(string err)
{
    /// Your code here...
}
void OnPresentScreen() { ... }
/**
 * Fired when a Banner Ad screen is presented.
 */
void OnPresentScreen()
{
    /// Your code here...
}
void OnDismissScreen() { ... }
/**
 * Fired when a Banner Ad screen is dismissed.
 */
void OnDismissScreen()
{
    /// Your code here...
}
void OnLeaveApplication() { ... }
/**
 * Fired when the App loses focus after a Banner Ad is clicked.
 */
void OnLeaveApplication()
{
    /// Your code here...
}
void OnReceiveAdInterstitial() { ... }
/**
 * Fired when an Interstitial Ad is received successfully.
 */
void OnReceiveAdInterstitial()
{
    /// Your code here...
}
void OnFailedToReceiveAdInterstitial(string err) { ... }
/**
 * Fired when an Interstitial Ad fails to be received.
 *
 * @param err
 *          string - The error string
 */
void OnFailedToReceiveAdInterstitial(string err)
{
    /// Your code here...
}
void OnPresentScreenInterstitial() { ... }
/**
 * Fired when an Interstitial Ad screen is presented.
 */
void OnPresentScreenInterstitial()
{
    /// Your code here...
}
void OnDismissScreenInterstitial() { ... }
/**
 * Fired when an Interstitial Ad screen is dismissed.
 */
void OnDismissScreenInterstitial()
{
    /// Your code here...
}
void OnLeaveApplicationInterstitial() { ... }
/**
 * Fired when the App loses focus after an Interstitial Ad is clicked.
 */
void OnLeaveApplicationInterstitial()
{
    /// Your code here...
}
void OnReceiveAdPrestitial() { ... }
/**
 * Fired when an Prestitial Ad is received successfully.
 */
void OnReceiveAdPrestitial()
{
    /// Your code here...
}
void OnFailedToReceiveAdPrestitial(string err) { ... }
/**
 * Fired when an Prestitial Ad fails to be received.
 *
 * @param err
 *          string - The error string
 */
void OnFailedToReceiveAdPrestitial(string err)
{
    /// Your code here...
}
void OnPresentScreenPrestitial() { ... }
/**
 * Fired when a Prestitial Ad screen is presented.
 */
void OnPresentScreenPrestitial()
{
    /// Your code here...
}
void OnDismissScreenPrestitial() { ... }
/**
 * Fired when a Prestitial Ad screen is dismissed.
 */
void OnDismissScreenPrestitial()
{
    /// Your code here...
}
void OnLeaveApplicationPrestitial() { ... }
/**
 * Fired when the App loses focus after a Prestitial Ad is clicked.
 */
void OnLeaveApplicationPrestitial()
{
    /// Your code here...
}

[7] Build your App now. To compile for iOS platform, you need to have Xcode 4.5 (with iOS SDK v6) or above 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 test with the "Test Mode" On. (Do it by regiestering your devices at MMedia.com Publisher Site. You can find your Device ID in logcat output if "Show Device Id In Log" field of MmediaAdAgent gameObject is checked.) 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!