private static void LoadPluginsForAdUnits(string[] adUnitIds) { foreach (var adUnitId in adUnitIds) { PluginsDict[adUnitId] = new MP(adUnitId); } Debug.Log(adUnitIds.Length + " AdUnits loaded for plugins:\n" + string.Join(", ", adUnitIds)); }
private static void LoadPluginsForAdUnits(string[] adUnitIds) { foreach (string str in adUnitIds) { PluginsDict[str] = new MoPubBinding(str); } Debug.Log(adUnitIds.Length + " AdUnits loaded for plugins:\n" + string.Join(", ", adUnitIds)); }
// Enables/disables location support for banners and interstitials public static void enableLocationSupport(bool shouldUseLocation) { #if UNITY_IPHONE MoPubBinding.enableLocationSupport(true); #elif UNITY_ANDROID MoPubAndroid.setLocationAwareness(MoPubLocationAwareness.NORMAL); #endif }
// Reports an app download to MoPub. iTunesAppId is iOS only. public static void reportApplicationOpen(string iTunesAppId = null) { #if UNITY_IPHONE MoPubBinding.reportApplicationOpen(iTunesAppId); #elif UNITY_ANDROID MoPubAndroid.reportApplicationOpen(); #endif }
/* * Rewarded Video API */ // Initializes the rewarded video system public static void initializeRewardedVideo() { #if UNITY_IPHONE MP.initializeRewardedVideo(); #elif UNITY_ANDROID MPRewardedVideo.initializeRewardedVideo(); #endif }
// Initializes the rewarded video system with the specified networks. public static void initializeRewardedVideo(MoPubRewardedNetwork[] networks) { #if UNITY_IPHONE MP.initializeRewardedVideoWithNetworks(networks); #elif UNITY_ANDROID MPRewardedVideo.initializeRewardedVideoWithNetworks(networks); #endif }
private void ShowMopubAdOnLevelEnd() { #if UNITY_ANDROID Debug.Log("----------- Show MoPub Ad State: " + MoPubAndroidManager.INTERSTITIAL_AD_STATE); if (MoPubAndroidManager.INTERSTITIAL_AD_STATE == MoPubAndroidManager.INTERSTITIAL_STATES.LOADED) { MoPubAndroid.showInterstitalAd(); Debug.Log("----------- Show MoPub Ad State: " + "SHOWN"); } #endif #if UNITY_IPHONE if (MoPubManager.INTERSTITIAL_AD_STATE == MoPubManager.INTERSTITIAL_STATES.LOADED) { MoPubBinding.showInterstitialAd(Constants.INTERSTITIAL_ID_IOS); } #endif }
public static string getSDKName() { if (_sdkName == null) { #if UNITY_EDITOR _sdkName = "no SDK loaded (not on a mobile device)"; #elif UNITY_ANDROID AndroidJavaClass _pluginClass = new AndroidJavaClass("com.mopub.unity.MoPubUnityPlugin"); string sdkVersion = _pluginClass.CallStatic <string> ("getSDKVersion"); _sdkName = "Android SDK v" + sdkVersion; #elif UNITY_IPHONE _sdkName = "iOS SDK v" + MoPubBinding.getSDKVersion(); #endif _sdkName = _sdkName.Replace("+unity", ""); } return(_sdkName); }
IEnumerator WaitForMopubAddOnMainMenu(float wait) { Debug.Log("----------- before :: " + MoPubAndroidManager.INTERSTITIAL_AD_STATE); yield return(new WaitForSeconds(wait)); #if UNITY_ANDROID if (MoPubAndroidManager.INTERSTITIAL_AD_STATE != MoPubAndroidManager.INTERSTITIAL_STATES.DISPLAYED && GameManager.Instance.GetCurrentGameState() == GameManager.GameState.MAINMENU) { ShowMopubAdOnMainMenu(); } #endif #if UNITY_IPHONE if (MoPubManager.INTERSTITIAL_AD_STATE == MoPubManager.INTERSTITIAL_STATES.LOADED) { MoPubManager.INTERSTITIAL_AD_STATE = MoPubManager.INTERSTITIAL_STATES.NONE; MoPubBinding.showInterstitialAd(Constants.INTERSTITIAL_ID_IOS); } #endif }
private void RequestForMopubAd() { localCount++; if (localCount == displayAdAfterLvl && !UserPrefs.isIgnoreAds) { Debug.Log("----------- Show MoPub Ad State: " + " Request sent"); #if UNITY_ANDROID if (MoPubAndroidManager.INTERSTITIAL_AD_STATE != MoPubAndroidManager.INTERSTITIAL_STATES.LOADED && MoPubAndroidManager.INTERSTITIAL_AD_STATE != MoPubAndroidManager.INTERSTITIAL_STATES.LOADING) { MoPubAndroid.requestInterstitalAd(Constants.INTERSTITIAL_ID_ANDROID); MoPubAndroidManager.INTERSTITIAL_AD_STATE = MoPubAndroidManager.INTERSTITIAL_STATES.LOADING; } #endif #if UNITY_IPHONE MoPubBinding.requestInterstitialAd(Constants.INTERSTITIAL_ID_IOS, null); #endif localCount = 0; } }
private void ShowMopubAdOnMainMenuScreen() { #if UNITY_ANDROID Debug.Log("----------- Show MoPub Ad State: " + MoPubAndroidManager.INTERSTITIAL_AD_STATE); if (MoPubAndroidManager.INTERSTITIAL_AD_STATE == MoPubAndroidManager.INTERSTITIAL_STATES.LOADED) { if (GameManager.Instance.GetCurrentGameState() == GameManager.GameState.MAINMENU) { MoPubAndroid.showInterstitalAd(); } } #endif #if UNITY_IPHONE if (MoPubManager.INTERSTITIAL_AD_STATE == MoPubManager.INTERSTITIAL_STATES.LOADED) { if (GameManager.Instance.GetCurrentGameState() == GameManager.GameState.MAINMENU) { MoPubBinding.showInterstitialAd(Constants.INTERSTITIAL_ID_IOS); } } #endif }
// Starts loading an interstitial ad public static void requestInterstitialAd(string adUnitId, string keywords = "") { MP.requestInterstitialAd(adUnitId, keywords); }
// Destroys the banner and removes it from view public static void destroyBanner() { MP.destroyBanner(); }
// Forces the usage of WKWebView if able. public static void forceWKWebView(bool shouldForce) { MoPubBinding.forceWKWebView(shouldForce); }
// If an interstitial ad is loaded this will take over the screen and show the ad public static void showInterstitialAd(string adUnitId) { MP.showInterstitialAd(adUnitId); }
// Initializes the rewarded video system public static void initializeRewardedVideo() { MP.initializeRewardedVideo(); }
// Starts loading a rewarded video ad public static void requestRewardedVideo(string adUnitId, List <MoPubMediationSetting> mediationSettings = null, string keywords = null, double latitude = LAT_LONG_SENTINEL, double longitude = LAT_LONG_SENTINEL) { MP.requestRewardedVideo(adUnitId, mediationSettings, keywords, latitude, longitude); }
// If a rewarded video ad is loaded this will take over the screen and show the ad public static void showRewardedVideo(string adUnitId) { MP.showRewardedVideo(adUnitId); }
// Creates a banner of the given type at the given position. bannerType is iOS only. #if UNITY_IPHONE public static void createBanner(string adUnitId, MoPubAdPosition position, MoPubBannerType bannerType = MoPubBannerType.Size320x50) { MoPubBinding.createBanner(bannerType, position, adUnitId); }
// Shows/hides the banner public static void showBanner(bool shouldShow) { MP.showBanner(shouldShow); }