/mopub-unity-ios-plugin

MoPub Unity iOS Plugin

BSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

mopub-unity-ios-plugin
======================

Build Instructions
------------------

In order to properly build the MoPub Unity Plugin you will need to use files from this repository (referred to as UnityPlugin in this document) and the MoPub iOS SDK found under the MoPubiOS/ directory at https://github.com/mopub/mopub-client (referred to as MoPubSdk in this document).

1. Import UnityPlugin's MoPubiOS.unitypackage into your Unity iOS Project

2. (Optional) Add UnityPlugin's Plugins/MoPub/testSupport/MoPubTestScene to the Unity build window [contains the MoPubGUIManager.cs example]

3. Use Unity Player to build your Unity iOS Project into an Xcode project

4. Copy the following source folders and files to the Classes/ folder of your Xcode project
  a. The complete contents of the MoPubSdk's MoPubSDK/ directory
  b. MoPubSdk's TouchJSON/ directory (including the parent directory)
  c. The MoPubBinding.m, MoPubManager.h, and MoPubManager.mm files from UnityPlugin

5. Make modifications to the included frameworks in Xcode's Build Phases
  a. Add the StoreKit.framework
  b. Add the AdSupport.framework and set it to Optional

6. Build and run your Xcode project

API Documentation
-----------------

Plugins/MoPub/MoPubBinding.cs exposes the following methods:

  // Enables/disables location support for banners and interstitials
  public static void enableLocationSupport( bool shouldUseLocation )

  // Creates a banner of the given type at the given position
  public static void createBanner( MoPubBannerType bannerType, MoPubAdPosition position, string adUnitId )

  // Destroys the banner and removes it from view
  public static void destroyBanner()

  // Shows/hides the banner
  public static void showBanner( bool shouldShow )

  // Refreshes the ad banner with optional keywords
  public static void refreshAd( string keywords )

  // Starts loading an interstitial ad
  public static void requestInterstitialAd( string adUnitId, string keywords )

  // If an interstitial ad is loaded this will take over the screen and show the ad
  public static void showInterstitialAd( string adUnitId )

  // Reports an app download to MoPub
  public static void reportApplicationOpen( string iTunesAppId )

Plugins/MoPub/MoPubManager.cs exposes the following methods:

  // Fired when an ad fails to load for the banner
  public void adViewDidFailToLoadAd( string empty )

  // Fired when an ad loads in the banner
  public void adViewDidLoadAd( string empty )

  // Fired when an interstitial ad is loaded and ready to be shown
  public void interstitialDidLoadAd( string empty )

  // Fired when an interstitial ad fails to load
  public void interstitialDidFailToLoadAd( string empty )

  // Fired when an interstitial ad is dismissed
  public void interstitialDidDismiss( string empty )

  // Fired when an interstitial ad expires
  public void interstitialDidExpire( string empty )

Plugins/MoPub/testSupport/MoPubGUIManager.cs provides an example of how this API may be consumed.