/// <summary> /// Whether the interstitial ad is ready to be shown or not. /// </summary> /// <param name="adUnitId">A string with the ad unit id.</param> public static bool IsInterstitialReady(string adUnitId) { ValidateInit(); MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { return(plugin.IsInterstitialReady()); } ReportAdUnitNotFound(adUnitId); return(false); }
/// <summary> /// Whether a rewarded video is ready to play for this ad unit. /// </summary> /// <param name="adUnitId">A string with the ad unit id.</param> /// <returns>`true` if a rewarded ad for the given ad unit id is loaded and ready to be shown; false othewise /// </returns> public static bool HasRewardedVideo(string adUnitId) { ValidateInit(); MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { return(plugin.HasRewardedVideo()); } ReportAdUnitNotFound(adUnitId); return(false); }
/// <summary> /// Selects the reward to give the user when the ad has finished playing. /// </summary> /// <param name="adUnitId">A string with the ad unit id.</param> /// <param name="selectedReward">See <see cref="MoPub.Reward"/>.</param> public static void SelectReward(string adUnitId, Reward selectedReward) { ValidateInit(); MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { plugin.SelectReward(selectedReward); } else { ReportAdUnitNotFound(adUnitId); } }
/// <summary> /// Destroys an already-loaded interstitial ad. /// </summary> /// <param name="adUnitId">A string with the ad unit id.</param> public static void DestroyInterstitialAd(string adUnitId) { ValidateInit(); MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { plugin.DestroyInterstitialAd(); } else { ReportAdUnitNotFound(adUnitId); } }
/// <summary> /// Enables or disables banners automatically refreshing every 30 seconds. /// </summary> /// <param name="adUnitId">A string with the ad unit id.</param> /// <param name="enabled">Whether to enable or disable autorefresh.</param> public static void SetAutorefresh(string adUnitId, bool enabled) { ValidateInit(); MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { plugin.SetAutorefresh(enabled); } else { ReportAdUnitNotFound(adUnitId); } }
public static void RequestNativeAd(string adUnitId) { ValidateInit(); MoPubLog.Log("RequestNativeAd", MoPubLog.AdLogEvent.LoadAttempted); MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { plugin.RequestNativeAd(); } else { ReportAdUnitNotFound(adUnitId); } }
/// <summary> /// If the rewarded video ad has loaded, this will take over the screen and show the ad. /// </summary> /// <param name="adUnitId">A string with the ad unit id.</param> /// <param name="customData">An optional string with custom data for the ad.</param> /// <remarks><see cref="MoPubManager.OnRewardedVideoLoadedEvent"/> must have been triggered already.</remarks> public static void ShowRewardedVideo(string adUnitId, string customData = null) { ValidateInit(); MoPubLog.Log("ShowRewardedVideo", MoPubLog.AdLogEvent.ShowAttempted); MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { plugin.ShowRewardedVideo(customData); } else { ReportAdUnitNotFound(adUnitId); } }
/// <summary> /// If the interstitial ad has loaded, this will take over the screen and show the ad. /// </summary> /// <param name="adUnitId">A string with the ad unit id.</param> /// <remarks><see cref="MoPubManager.OnInterstitialLoadedEvent"/> must have been triggered already.</remarks> public static void ShowInterstitialAd(string adUnitId) { ValidateInit(); MoPubLog.Log("ShowInterstitialAd", MoPubLog.AdLogEvent.ShowAttempted); MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { plugin.ShowInterstitialAd(); } else { ReportAdUnitNotFound(adUnitId); } }
/// <summary> /// Requests an interstitial ad with the given (optional) keywords to be loaded. The two possible resulting events /// are <see cref="MoPubManager.OnInterstitialLoadedEvent"/> and /// <see cref="MoPubManager.OnInterstitialFailedEvent"/>. /// </summary> /// <param name="adUnitId">A string with the ad unit id.</param> /// <param name="keywords">An optional comma-separated string with the desired keywords for this ad.</param> /// <param name="userDataKeywords">An optional comma-separated string with user data for this ad.</param> /// <remarks>If a user is in a General Data Protection Regulation (GDPR) region and MoPub doesn't obtain consent /// from the user, "keywords" will be sent to the server but "userDataKeywords" will be excluded. /// (See <see cref="CanCollectPersonalInfo"/>).</remarks> public static void RequestInterstitialAd(string adUnitId, string keywords = "", string userDataKeywords = "") { ValidateInit(); MoPubLog.Log("RequestInterstitialAd", MoPubLog.AdLogEvent.LoadAttempted); MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { plugin.RequestInterstitialAd(keywords, userDataKeywords); } else { ReportAdUnitNotFound(adUnitId); } }
/// <summary> /// Refreshes the banner ad regardless of whether autorefresh is enabled or not. /// </summary> /// <param name="adUnitId">A string with the ad unit id.</param> public static void ForceRefresh(string adUnitId) { ValidateInit(); MoPubLog.Log("ForceRefresh", MoPubLog.AdLogEvent.ShowAttempted); MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { plugin.ForceRefresh(); } else { ReportAdUnitNotFound(adUnitId); } }
/// <summary> /// Sets the desired keywords and reloads the banner ad. /// </summary> /// <param name="adUnitId">A string with the ad unit id.</param> /// <param name="keywords">A comma-separated string with the desired keywords for this ad.</param> /// <param name="userDataKeywords">An optional comma-separated string with user data for this ad.</param> /// <remarks>If a user is in a General Data Protection Regulation (GDPR) region and MoPub doesn't obtain consent /// from the user, "keywords" will be sent to the server but "userDataKeywords" will be excluded. /// (See <see cref="CanCollectPersonalInfo"/>).</remarks> public static void RefreshBanner(string adUnitId, string keywords, string userDataKeywords = "") { ValidateInit(); MoPubLog.Log("RefreshBanner", MoPubLog.AdLogEvent.ShowAttempted); MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { plugin.RefreshBanner(keywords, userDataKeywords); } else { ReportAdUnitNotFound(adUnitId); } }
/// <summary> /// Retrieves a list of available rewards for the given ad unit id. /// </summary> /// <param name="adUnitId">A string with the ad unit id.</param> /// <returns>A list of <see cref="MoPub.Reward"/>s for the given ad unit id.</returns> public static List <Reward> GetAvailableRewards(string adUnitId) { ValidateInit(); MoPubAdUnit plugin; if (!AdUnits.TryGetValue(adUnitId, out plugin)) { ReportAdUnitNotFound(adUnitId); return(null); } var rewards = plugin.GetAvailableRewards(); Debug.Log(String.Format("GetAvailableRewards found {0} rewards for ad unit {1}", rewards.Count, adUnitId)); return(rewards); }
public static void CreateBanner(string adUnitId, AdPosition position, BannerType bannerType = BannerType.Size320x50) { ValidateInit(); MoPubLog.Log("CreateBanner", MoPubLog.AdLogEvent.LoadAttempted); MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { plugin.CreateBanner(position, bannerType); } else { ReportAdUnitNotFound(adUnitId); } }
/// <summary> /// Requests an rewarded video ad with the given (optional) configuration to be loaded. The two possible resulting /// events are <see cref="MoPubManager.OnRewardedVideoLoadedEvent"/> and /// <see cref="MoPubManager.OnRewardedVideoFailedEvent"/>. /// </summary> /// <param name="adUnitId">A string with the ad unit id.</param> /// <param name="mediationSettings">See <see cref="MoPub.SdkConfiguration.MediationSettings"/>.</param> /// <param name="keywords">An optional comma-separated string with the desired keywords for this ad.</param> /// <param name="userDataKeywords">An optional comma-separated string with user data for this ad.</param> /// <param name="latitude">An optional location latitude to be used for this ad.</param> /// <param name="longitude">An optional location longitude to be used for this ad.</param> /// <param name="customerId">An optional string to indentify this user within this app. </param> /// <remarks>If a user is in a General Data Protection Regulation (GDPR) region and MoPub doesn't obtain consent /// from the user, "keywords" will be sent to the server but "userDataKeywords" will be excluded. /// (See <see cref="CanCollectPersonalInfo"/>).</remarks> public static void RequestRewardedVideo(string adUnitId, List <LocalMediationSetting> mediationSettings = null, string keywords = null, string userDataKeywords = null, double latitude = LatLongSentinel, double longitude = LatLongSentinel, string customerId = null) { ValidateInit(); MoPubLog.Log("RequestRewardedVideo", MoPubLog.AdLogEvent.LoadAttempted); MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { plugin.RequestRewardedVideo(mediationSettings, keywords, userDataKeywords, latitude, longitude, customerId); } else { ReportAdUnitNotFound(adUnitId); } }
/// <summary> /// Shows or hides an already-loaded banner ad. /// </summary> /// <param name="adUnitId">A string with the ad unit id.</param> /// <param name="shouldShow">A bool with `true` to show the ad, or `false` to hide it.</param> /// <remarks>Banners are automatically shown after first loading.</remarks> public static void ShowBanner(string adUnitId, bool shouldShow) { ValidateInit(); if (shouldShow) { MoPubLog.Log("ShowBanner", MoPubLog.AdLogEvent.ShowAttempted); } MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { plugin.ShowBanner(shouldShow); } else { ReportAdUnitNotFound(adUnitId); } }
/// <summary> /// Requests a banner ad and immediately shows it once loaded. /// </summary> /// <param name="adUnitId">A string with the ad unit id.</param> /// <param name="position">Where in the screen to position the loaded ad. See <see cref="MoPub.AdPosition"/>. /// </param> /// <param name="maxAdSize">The maximum size of the banner to load. See <see cref="MoPub.MaxAdSize"/>.</param> public static void RequestBanner(string adUnitId, AdPosition position, MaxAdSize maxAdSize = MaxAdSize.Width320Height50) { ValidateInit(); var width = maxAdSize.Width(); var height = maxAdSize.Height(); MoPubLog.Log("RequestBanner", MoPubLog.AdLogEvent.LoadAttempted); MoPubLog.Log("RequestBanner", "Size requested: " + width + "x" + height); MoPubAdUnit plugin; if (AdUnits.TryGetValue(adUnitId, out plugin)) { plugin.RequestBanner(width, height, position); } else { ReportAdUnitNotFound(adUnitId); } }