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:
#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:
OnAdLoadedEvent (string adUnitId, string height) OnAdFailedEvent (string adUnitId, string errorMsg) OnAdClickedEvent (string adUnitId) OnAdExpandedEvent (string adUnitId) OnAdCollapsedEvent (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 May 08, 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.)