Example #1
0
    public void EmitInterstitialClickedEvent(string argsJson)
    {
        var args     = MoPubUtils.DecodeArgs(argsJson, min: 1);
        var adUnitId = args[0];

        MoPubLog.Log("EmitInterstitialClickedEvent", MoPubLog.AdLogEvent.Tapped);
        var evt = OnInterstitialClickedEvent;

        if (evt != null)
        {
            evt(adUnitId);
        }
    }
Example #2
0
    public void EmitRewardedVideoExpiredEvent(string argsJson)
    {
        var args     = MoPubUtils.DecodeArgs(argsJson, min: 1);
        var adUnitId = args[0];

        MoPubLog.Log("EmitRewardedVideoExpiredEvent", MoPubLog.AdLogEvent.Expired);
        var evt = OnRewardedVideoExpiredEvent;

        if (evt != null)
        {
            evt(adUnitId);
        }
    }
Example #3
0
    public void EmitAdCollapsedEvent(string argsJson)
    {
        var args     = MoPubUtils.DecodeArgs(argsJson, min: 1);
        var adUnitId = args[0];

        MoPubLog.Log("EmitAdCollapsedEvent", MoPubLog.AdLogEvent.Collapsed);
        var evt = OnAdCollapsedEvent;

        if (evt != null)
        {
            evt(adUnitId);
        }
    }
Example #4
0
    public void EmitConsentDialogFailedEvent(string argsJson)
    {
        var args = MoPubUtils.DecodeArgs(argsJson, min: 1);
        var err  = args[0];

        MoPubLog.Log("EmitConsentDialogFailedEvent", MoPubLog.ConsentLogEvent.LoadFailed, err);
        var evt = OnConsentDialogFailedEvent;

        if (evt != null)
        {
            evt(err);
        }
    }
    public void EmitRewardedVideoShownEvent(string argsJson)
    {
        var args     = DecodeArgs(argsJson, min: 1);
        var adUnitId = args[0];

        MoPubLog.Log("EmitRewardedVideoShownEvent", MoPubLog.AdLogEvent.ShowSuccess);
        var evt = OnRewardedVideoShownEvent;

        if (evt != null)
        {
            evt(adUnitId);
        }
    }
    public void EmitInterstitialDidExpireEvent(string argsJson)
    {
        var args     = DecodeArgs(argsJson, min: 1);
        var adUnitId = args[0];

        MoPubLog.Log("EmitInterstitialDidExpireEvent", MoPubLog.AdLogEvent.Expired);
        var evt = OnInterstitialExpiredEvent;

        if (evt != null)
        {
            evt(adUnitId);
        }
    }
Example #7
0
 /// <summary>
 /// If the MoPub consent dialog is loaded, this will take over the screen and show it.
 /// <para>
 /// For platform-specific implementations, see
 /// MoPubAndroid.<see cref="MoPubAndroid.ShowConsentDialog()"/> and
 /// MoPubiOS.<see cref="MoPubiOS.ShowConsentDialog()"/>.
 /// </para>
 /// </summary>
 public static void ShowConsentDialog()
 {
     MoPubLog.Log("ShowConsentDialog", MoPubLog.ConsentLogEvent.ShowAttempted);
     if (!IsConsentDialogReady)
     {
         Debug.LogError("Called ShowConsentDialog before consent dialog loaded!");
         return;
     }
     WaitOneFrame(() => {
         Debug.Log("When running on a mobile device, the consent dialog would appear now.");
         MoPubManager.Instance.EmitConsentDialogShownEvent();
     });
 }
Example #8
0
    /// See MoPubUnityEditor.<see cref="MoPubUnityEditor.ShowRewardedVideo(string,string)"/>
    public static void ShowRewardedVideo(string adUnitId, string customData = null)
    {
        MoPubLog.Log("ShowRewardedVideo", MoPubLog.AdLogEvent.ShowAttempted);
        MP plugin;

        if (PluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.ShowRewardedVideo(customData);
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Example #9
0
    public void EmitNativeFailEvent(string argsJson)
    {
        var args     = DecodeArgs(argsJson, min: 2);
        var adUnitId = args[0];
        var error    = args[1];

        MoPubLog.Log("EmitNativeFailEvent", MoPubLog.AdLogEvent.LoadFailed, adUnitId, error);
        var evt = OnNativeFailEvent;

        if (evt != null)
        {
            evt(adUnitId, error);
        }
    }
Example #10
0
    /// See MoPubUnityEditor.<see cref="MoPubUnityEditor.ShowBanner(string,bool)"/>
    public static void ShowBanner(string adUnitId, bool shouldShow)
    {
        MoPubLog.Log("ShowBanner", MoPubLog.AdLogEvent.ShowAttempted);
        MP plugin;

        if (PluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.ShowBanner(shouldShow);
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Example #11
0
 /// See MoPubUnityEditor.<see cref="MoPubUnityEditor.InitializeSdk(MoPub.SdkConfiguration)"/>
 public static void InitializeSdk(SdkConfiguration sdkConfiguration)
 {
     logLevel = sdkConfiguration.LogLevel;
     MoPubLog.Log("InitializeSdk", MoPubLog.SdkLogEvent.InitStarted);
     ValidateAdUnitForSdkInit(sdkConfiguration.AdUnitId);
     PluginClass.CallStatic(
         "initializeSdk", sdkConfiguration.AdUnitId,
         sdkConfiguration.AdditionalNetworksString,
         sdkConfiguration.MediationSettingsJson,
         sdkConfiguration.AllowLegitimateInterest,
         (int)sdkConfiguration.LogLevel,
         sdkConfiguration.NetworkConfigurationsJson,
         sdkConfiguration.MoPubRequestOptionsJson);
 }
Example #12
0
    /// See MoPubUnityEditor.<see cref="MoPubUnityEditor.RefreshBanner(string,string,string)"/>
    public static void RefreshBanner(string adUnitId, string keywords, string userDataKeywords = "")
    {
        MoPubLog.Log("RefreshBanner", MoPubLog.AdLogEvent.ShowAttempted);
        MP plugin;

        if (PluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.RefreshBanner(keywords, userDataKeywords);
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Example #13
0
    public void EmitRewardedVideoFailedEvent(string argsJson)
    {
        var args     = MoPubUtils.DecodeArgs(argsJson, min: 2);
        var adUnitId = args[0];
        var error    = args[1];

        MoPubLog.Log("EmitRewardedVideoFailedEvent", MoPubLog.AdLogEvent.LoadFailed, adUnitId, error);
        var evt = OnRewardedVideoFailedEvent;

        if (evt != null)
        {
            evt(adUnitId, error);
        }
    }
Example #14
0
    public static void RequestNativeAd(string adUnitId)
    {
        MoPubLog.Log("RequestNativeAd", MoPubLog.AdLogEvent.LoadAttempted);
        MPNative plugin;

        if (NativePluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.RequestNativeAd();
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Example #15
0
    /// See MoPubUnityEditor.<see cref="MoPubUnityEditor.ForceRefresh(string)"/>
    public static void ForceRefresh(string adUnitId)
    {
        MoPubLog.Log("ForceRefresh", MoPubLog.AdLogEvent.ShowAttempted);
        MP plugin;

        if (PluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.ForceRefresh();
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Example #16
0
    /// See MoPubUnityEditor.<see cref="MoPubUnityEditor.RequestInterstitialAd(string,string,string)"/>
    public static void RequestInterstitialAd(string adUnitId, string keywords = "", string userDataKeywords = "")
    {
        MoPubLog.Log("RequestInterstitialAd", MoPubLog.AdLogEvent.LoadAttempted);
        MP plugin;

        if (PluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.RequestInterstitialAd(keywords, userDataKeywords);
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Example #17
0
    /// See MoPubUnityEditor.<see cref="MoPubUnityEditor.ShowInterstitialAd(string)"/>
    public static void ShowInterstitialAd(string adUnitId)
    {
        MoPubLog.Log("ShowInterstitialAd", MoPubLog.AdLogEvent.ShowAttempted);
        MP plugin;

        if (PluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.ShowInterstitialAd();
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Example #18
0
    /// See MoPubUnityEditor.<see cref="MoPubUnityEditor.CreateBanner(string,MoPubBase.AdPosition,MoPubBase.BannerType)"/>
    public static void CreateBanner(string adUnitId, AdPosition position, BannerType bannerType = BannerType.Size320x50)
    {
        MoPubLog.Log("CreateBanner", MoPubLog.AdLogEvent.LoadAttempted);
        MP plugin;

        if (PluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.CreateBanner(bannerType, position);
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Example #19
0
    /// See MoPubUnityEditor.<see cref="MoPubUnityEditor.CreateBanner(string,MoPubBase.AdPosition,MoPubBase.BannerType)"/>
    public static void CreateBanner(string adUnitId, AdPosition position)
    {
        MoPubLog.Log("CreateBanner", MoPubLog.AdLogEvent.LoadAttempted);
        MPBanner plugin;

        if (BannerPluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.CreateBanner(position);
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Example #20
0
    public void EmitRewardedVideoReceivedRewardEvent(string argsJson)
    {
        var args      = DecodeArgs(argsJson, min: 3);
        var adUnitId  = args[0];
        var label     = args[1];
        var amountStr = args[2];

        MoPubLog.Log("EmitRewardedVideoReceivedRewardEvent", MoPubLog.AdLogEvent.ShouldReward, label, amountStr);
        var evt = OnRewardedVideoReceivedRewardEvent;

        if (evt != null)
        {
            evt(adUnitId, label, float.Parse(amountStr));
        }
    }
Example #21
0
 /// <summary>
 /// If the interstitial ad has loaded, this will take over the screen and show the ad.
 /// <para>
 /// For platform-specific implementations, see
 /// MoPubAndroid.<see cref="MoPubAndroid.ShowInterstitialAd(string)"/> and
 /// MoPubiOS.<see cref="MoPubiOS.ShowInterstitialAd(string)"/>.
 /// </para>
 /// </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)
 {
     MoPubLog.Log("ShowInterstitialAd", MoPubLog.AdLogEvent.ShowAttempted);
     if (CheckAdUnitRequested(adUnitId))
     {
         WaitOneFrame(() => {
             var json = ArgsToJson(adUnitId);
             MoPubManager.Instance.EmitInterstitialShownEvent(json);
             WaitOneFrame(() => {
                 MoPubManager.Instance.EmitInterstitialDismissedEvent(json);
                 SimulateApplicationResume();
             });
         });
     }
 }
Example #22
0
    public void EmitRewardedVideoReceivedRewardEvent(string argsJson)
    {
        var args      = MoPubUtils.DecodeArgs(argsJson, min: 3);
        var adUnitId  = args[0];
        var label     = args[1];
        var amountStr = args[2];

        MoPubLog.Log("EmitRewardedVideoReceivedRewardEvent", MoPubLog.AdLogEvent.ShouldReward, label, amountStr);
        var evt = OnRewardedVideoReceivedRewardEvent;

        if (evt != null)
        {
            evt(adUnitId, label, Single.Parse(amountStr, CultureInfo.InvariantCulture));
        }
    }
Example #23
0
    // Banner Listeners


    public void EmitAdLoadedEvent(string argsJson)
    {
        var args      = DecodeArgs(argsJson, min: 2);
        var adUnitId  = args[0];
        var heightStr = args[1];

        MoPubLog.Log("EmitAdLoadedEvent", MoPubLog.AdLogEvent.LoadSuccess);
        MoPubLog.Log("EmitAdLoadedEvent", MoPubLog.AdLogEvent.ShowSuccess);
        var evt = OnAdLoadedEvent;

        if (evt != null)
        {
            evt(adUnitId, float.Parse(heightStr));
        }
    }
Example #24
0
 /// <summary>
 /// If the rewarded video ad has loaded, this will take over the screen and show the ad.
 /// <para>
 /// For platform-specific implementations, see
 /// MoPubAndroid.<see cref="MoPubAndroid.ShowRewardedVideo(string,string)"/> and
 /// MoPubiOS.<see cref="MoPubiOS.ShowRewardedVideo(string,string)"/>.
 /// </para>
 /// </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)
 {
     MoPubLog.Log("ShowRewardedVideo", MoPubLog.AdLogEvent.ShowAttempted);
     if (CheckAdUnitRequested(adUnitId))
     {
         WaitOneFrame(() => {
             var json = ArgsToJson(adUnitId);
             MoPubManager.Instance.EmitRewardedVideoShownEvent(json);
             WaitOneFrame(() => {
                 MoPubManager.Instance.EmitRewardedVideoClosedEvent(json);
                 SimulateApplicationResume();
             });
         });
     }
 }
Example #25
0
    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);
        }
    }
Example #26
0
    /// See MoPubUnityEditor.<see cref="MoPubUnityEditor.RequestBanner(string,MoPub.AdPosition,MoPub.MaxAdSize)"/>
    public static void RequestBanner(string adUnitId, AdPosition position,
                                     MaxAdSize maxAdSize = MaxAdSize.Width320Height50)
    {
        MoPubLog.Log("RequestBanner", MoPubLog.AdLogEvent.LoadAttempted);
        MoPubLog.Log("RequestBanner", "Size requested: " + maxAdSize.Width() + "x" + maxAdSize.Height());
        MPBanner plugin;

        if (BannerPluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.RequestBanner(maxAdSize.Width(), maxAdSize.Height(), position);
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Example #27
0
    public void EmitConsentStatusChangedEvent(string argsJson)
    {
        var args                   = DecodeArgs(argsJson, min: 3);
        var oldConsent             = MoPub.Consent.FromString(args[0]);
        var newConsent             = MoPub.Consent.FromString(args[1]);
        var canCollectPersonalInfo = args[2].ToLower() == "true";

        MoPubLog.Log("EmitConsentStatusChangedEvent", MoPubLog.ConsentLogEvent.Updated, oldConsent, newConsent,
                     canCollectPersonalInfo, "unknown");
        var evt = OnConsentStatusChangedEvent;

        if (evt != null)
        {
            evt(oldConsent, newConsent, canCollectPersonalInfo);
        }
    }
Example #28
0
    /// See MoPubUnityEditor.<see cref="MoPubUnityEditor.RequestRewardedVideo(string,System.Collections.Generic.List{MoPubBase.LocalMediationSetting},string,string,double,double,string)"/>
    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)
    {
        MoPubLog.Log("RequestRewardedVideo", MoPubLog.AdLogEvent.LoadAttempted);
        MP plugin;

        if (PluginsDict.TryGetValue(adUnitId, out plugin))
        {
            plugin.RequestRewardedVideo(mediationSettings, keywords, userDataKeywords, latitude, longitude, customerId);
        }
        else
        {
            ReportAdUnitNotFound(adUnitId);
        }
    }
Example #29
0
    // Banner Listeners


    public void EmitAdLoadedEvent(string argsJson)
    {
        var args     = MoPubUtils.DecodeArgs(argsJson, min: 3);
        var adUnitId = args[0];
        var width    = args[1];
        var height   = args[2];

        MoPubLog.Log("EmitAdLoadedEvent", MoPubLog.AdLogEvent.LoadSuccess);
        MoPubLog.Log("EmitAdLoadedEvent", "Size received: {0}x{1}", width, height);
        MoPubLog.Log("EmitAdLoadedEvent", MoPubLog.AdLogEvent.ShowSuccess);
        var evt = OnAdLoadedEvent;

        if (evt != null)
        {
            evt(adUnitId, Single.Parse(height, CultureInfo.InvariantCulture));
        }
    }
Example #30
0
    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);
        }
    }