Banner Integration for Unity
Banner ads usually appear at the top or bottom of your app’s screen. Adding one to your app takes just a few lines of code.
Make sure you only call this once in the lifecycle of your app.
To create a banner in the Unity script file:
Create a banner:
MoPub.createBanner (bannerAdUnit, MoPubAdPosition.BottomRight);
Show or hide the banner (this is optional; the banner is shown by default):
MoPub.showBanner (bannerAdUnit, true); // shows the banner MoPub.showBanner (bannerAdUnit, false); // hides the banner
Destroy the banner:
If your game is distributed on iOS and Android, you only need to import the plugin once, but you must create different ad units for each platform:
```csharp #if UNITY_IOS MoPub.createBanner("REPLACE_BY_IPHONE_AD_UNIT_ID_HERE", MoPubAdPosition.BottomCenter ); #elif UNITY_ANDROID MoPub.createBanner("REPLACE_BY_ANDROID_AD_UNIT_ID_HERE", MoPubAdPosition.BottomCenter ); #endif ```
The following are the banner-related callback handlers:
void onAdLoaded (string height)
void onAdFailed (string errorMsg)
void onAdClicked (string adUnitId)
void onAdExpanded (string adUnitId)
void onAdCollapsed (string adUnitId)
Only create a banner ad view when you display it to the user.
If the user navigates from a screen with a banner on it to a screen that does not have a banner, destroy or hide the banner.
Last updated March 04, 2019
TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.
© 2019 MoPub (a division of Twitter, Inc.)