public void PlayAd(Dictionary <string, object> options, string placementId)
    {
        InvokeSafelyOnUIThreadAsync(delegate
        {
            if (sdk != null && sdk.IsAdPlayable(placementId))
            {
                if (options == null)
                {
                    options = new Dictionary <string, object>();
                }

                cfg = new AdConfig();
                SetAdConfig(cfg, options);
                if (options.ContainsKey(OptionConstants.FlexCloseSec) && options[OptionConstants.FlexCloseSec] is string)
                {
                    int seconds = 0;
                    if (int.TryParse((string)options[OptionConstants.FlexCloseSec], out seconds))
                    {
                        sdk.SetFlexViewCloseTimeInSec(placementId, seconds);
                    }
                    else
                    {
                        VungleLog.Log(VungleLog.Level.Warning, VungleLog.Context.LogEvent, "PlayAd", "FlexViewCloseTime was not an integer.");
                    }
                }
                sdk.PlayAd(cfg, placementId);
            }
        });
    }
Ejemplo n.º 2
0
 private static void OnWarning(string warning)
 {
     VungleLog.Log(VungleLog.Level.Debug, VungleLog.Context.LogEvent, "SendOnWarningEvent",
                   "Vungle.onWarning => From Unity:" + warning);
     if (onWarningEvent != null)
     {
         onWarningEvent(warning);
     }
 }
Ejemplo n.º 3
0
 private static void OnError(string error)
 {
     VungleLog.Log(VungleLog.Level.Debug, VungleLog.Context.LogEvent, "SendOnErrorEvent",
                   "Vungle.onWarning => From Unity:" + error);
     if (onErrorEvent != null)
     {
         onErrorEvent(error);
     }
 }
Ejemplo n.º 4
0
 public static void updateConsentStatus(Consent consent, string version = "1.0")
 {
     try
     {
         helper.UpdateConsentStatus(consent, version);
     }
     catch (Exception e)
     {
         VungleLog.Log(VungleLog.Level.Error, "updateConsentStatus", "Vungle.updateConsentStatus", e.Message);
     }
 }
Ejemplo n.º 5
0
 public static void updateCCPAStatus(Consent consent)
 {
     try
     {
         helper.UpdateCCPAStatus(consent);
     }
     catch (Exception e)
     {
         VungleLog.Log(VungleLog.Level.Error, "updateCCPAStatus", "Vungle.updateCCPAStatus", e.Message);
     }
 }
Ejemplo n.º 6
0
 public static void init(string appId, bool initHeaderBiddingDelegate)
 {
     try
     {
         helper.Init(appId, initHeaderBiddingDelegate);
     }
     catch (Exception e)
     {
         VungleLog.Log(VungleLog.Level.Error, "init", "Vungle.init", e.Message);
     }
 }
Ejemplo n.º 7
0
 public static void setLogEnable(bool enable)
 {
     try
     {
         helper.SetLogEnable(enable);
     }
     catch (Exception e)
     {
         VungleLog.Log(VungleLog.Level.Error, "setLogEnable", "Vungle.setLogEnable", e.Message);
     }
 }
Ejemplo n.º 8
0
 public static void setSoundEnabled(bool isEnabled)
 {
     try
     {
         helper.SetSoundEnabled(isEnabled);
     }
     catch (Exception e)
     {
         VungleLog.Log(VungleLog.Level.Error, "setSoundEnabled", "Vungle.setSoundEnabled", e.Message);
     }
 }
Ejemplo n.º 9
0
 public static void onPause()
 {
     try
     {
         helper.OnPause();
     }
     catch (Exception e)
     {
         VungleLog.Log(VungleLog.Level.Error, "onPause", "Vungle.onPause", e.Message);
     }
 }
Ejemplo n.º 10
0
 public static void playAd(string placementId)
 {
     try
     {
         helper.PlayAd(placementId);
     }
     catch (Exception e)
     {
         VungleLog.Log(VungleLog.Level.Error, "playAd", "Vungle.playAd", e.Message);
     }
 }
Ejemplo n.º 11
0
 public static void init(string appId)
 {
     try
     {
         helper.Init(appId);
     }
     catch (Exception e)
     {
         VungleLog.Log(VungleLog.Level.Error, "init", "Vungle.init", e.Message);
     }
 }
Ejemplo n.º 12
0
 public static bool isAdvertAvailable(string placementId, VungleBannerSize adSize)
 {
     try
     {
         return(helper.IsAdvertAvailable(placementId, adSize));
     }
     catch (Exception e)
     {
         VungleLog.Log(VungleLog.Level.Error, "isAdvertAvailable", "Vungle.isAdvertAvailable", e.Message);
         return(false);
     }
 }
Ejemplo n.º 13
0
 public static bool closeAd(string placementId)
 {
     try
     {
         return(helper.CloseAd(placementId));
     }
     catch (Exception e)
     {
         VungleLog.Log(VungleLog.Level.Error, "closeAd", "Vungle.closeAd", e.Message);
         return(false);
     }
 }
Ejemplo n.º 14
0
    /**
     * Close Banner with given placementId
     *
     * placementId String
     */
    public void CloseBanner(string placementId)
    {
#if !UNITY_2019_1 && !UNITY_2019_2
        InvokeSafelyOnUIThreadAsync(delegate
        {
            sdk.CloseBanner(placementId);
        });
#else
        VungleLog.Log(VungleLog.Level.Error, VungleLog.Context.LogEvent, "VungleWindows.CloseBanner",
                      "2019.1 and 2019.2 crashes when instantiating a core class for banners, but it is fixed in 2019.3");
#endif
    }
Ejemplo n.º 15
0
 public static Consent getCCPAStatus()
 {
     try
     {
         return(helper.GetCCPAStatus());
     }
     catch (Exception e)
     {
         VungleLog.Log(VungleLog.Level.Error, "getCCPAStatus", "Vungle.getCCPAStatus", e.Message);
         return(Consent.Undefined);
     }
 }
Ejemplo n.º 16
0
 public static void closeBanner(string placementId)
 {
     VungleLog.Log(VungleLog.Level.Debug, VungleLog.Context.LogEvent, "Vungle.closeBanner",
                   GetLogMessage("closing Banner", placementId));
     try
     {
         helper.CloseBanner(placementId);
     }
     catch (Exception e)
     {
         VungleLog.Log(VungleLog.Level.Error, "closeBanner", "Vungle.closeBanner", e.Message);
     }
 }
Ejemplo n.º 17
0
 /**
  * Load Banner of given AdSize and at given AdPosition
  *
  * placementId String
  * adSize AdSize Size of the banner
  * adPosition AdPosition Position of the Banner on screen
  */
 public static void loadBanner(string placementId, VungleBannerSize adSize, VungleBannerPosition adPosition)
 {
     VungleLog.Log(VungleLog.Level.Debug, VungleLog.Context.LogEvent, "Vungle.loadBanner",
                   GetLogMessage("loading Banner", placementId));
     try
     {
         helper.LoadBanner(placementId, adSize, adPosition);
     }
     catch (Exception e)
     {
         VungleLog.Log(VungleLog.Level.Error, "loadBanner", "Vungle.loadBanner", e.Message);
     }
 }
Ejemplo n.º 18
0
    private static void OnLog(string log)
    {
        VungleLog.Log(VungleLog.Level.Debug, VungleLog.Context.LogEvent, "SendOnLogEvent", "An log event. Log message is' " + log + "'.");
        if (onLogEvent != null)
        {
#if UNITY_WSA_10_0 || UNITY_WINRT_8_1 || UNITY_METRO
            VungleSceneLoom.Loom.QueueOnMainThread(() =>
            {
                onLogEvent(log);
            });
#else
            onLogEvent(log);
#endif
        }
    }
Ejemplo n.º 19
0
    private static void OnInitialize()
    {
        VungleLog.Log(VungleLog.Level.Debug, VungleLog.Context.SDKInitialization, "SendOnInitializeEvent", "SDK is initialized");
        if (onInitializeEvent != null)
        {
#if UNITY_WSA_10_0 || UNITY_WINRT_8_1 || UNITY_METRO
            VungleSceneLoom.Loom.QueueOnMainThread(() =>
            {
                onInitializeEvent();
            });
#else
            onInitializeEvent();
#endif
        }
    }
Ejemplo n.º 20
0
 private void InvokeSafelyOnUIThreadAsync(Action action)
 {
     UnityEngine.WSA.Application.InvokeOnUIThread(() =>
     {
         try
         {
             action();
         }
         catch (Exception e)
         {
             VungleLog.Log(VungleLog.Level.Error, VungleLog.Context.LogEvent, "InvokeSafelyOnUIThreadAsync",
                           string.Format("Failed to perform action on UI thread:\n{0}", e.ToString()));
         }
     }, false);
 }
Ejemplo n.º 21
0
    /**
     * Load Banner of given AdSize and at given AdPosition
     *
     * placementId String
     * adSize AdSize Size of the banner
     * adPosition AdPosition Position of the Banner on screen
     */

    public void LoadBanner(string placementId, Vungle.VungleBannerSize adSize, Vungle.VungleBannerPosition adPosition)
    {
#if !UNITY_2019_1 && !UNITY_2019_2
        InvokeSafelyOnUIThreadAsync(delegate
        {
            SetBannerGrid(delegate
            {
                sdk.LoadBanner(placementId, (int)adSize + 1, (int)adPosition);
            });
        });
#else
        VungleLog.Log(VungleLog.Level.Error, VungleLog.Context.LogEvent, "VungleWindows.LoadBanner",
                      "2019.1 and 2019.2 crashes when instantiating a core class for banners, but it is fixed in 2019.3");
#endif
    }
Ejemplo n.º 22
0
    private static void AdPlayable(string placementId, bool playable)
    {
        VungleLog.Log(VungleLog.Level.Debug, VungleLog.Context.AdLifecycle, "SendAdPlayableEvent",
                      string.Format("Placement {0} - Playable status {1}", placementId, playable.ToString()));
        if (adPlayableEvent != null)
        {
#if UNITY_WSA_10_0 || UNITY_WINRT_8_1 || UNITY_METRO
            VungleSceneLoom.Loom.QueueOnMainThread(() =>
            {
                adPlayableEvent(placementId, playable);
            });
#else
            adPlayableEvent(placementId, playable);
#endif
        }
    }
Ejemplo n.º 23
0
    public static void playAd(Dictionary <string, object> options, string placementId)
    {
        if (options == null)
        {
            options = new Dictionary <string, object>();
        }

        try
        {
            helper.PlayAd(options, placementId);
        }
        catch (Exception e)
        {
            VungleLog.Log(VungleLog.Level.Error, "playAd", "Vungle.playAd", e.Message);
        }
    }
Ejemplo n.º 24
0
    private static void AdFinished(string placementId, AdFinishedEventArgs args)
    {
        VungleLog.Log(VungleLog.Level.Debug, VungleLog.Context.AdLifecycle, "SendOnAdFinishedEvent",
                      string.Format("An ad finished displaying for {0}", placementId));
        if (onAdFinishedEvent != null)
        {
#if UNITY_WSA_10_0 || UNITY_WINRT_8_1 || UNITY_METRO
            VungleSceneLoom.Loom.QueueOnMainThread(() =>
            {
                onAdFinishedEvent(placementId, args);
            });
#else
            onAdFinishedEvent(placementId, args);
#endif
        }
    }
Ejemplo n.º 25
0
 static VungleManager()
 {
     // try/catch this so that we can warn users if they try to stick this script on a GO manually
     try
     {
         // create a new GO for our manager
         var go = new GameObject("VungleManager");
         go.AddComponent <VungleManager>();
         DontDestroyOnLoad(go);
     }
     catch
     {
         VungleLog.Log(VungleLog.Level.Error, VungleLog.Context.SDKInitialization, "VungleManager",
                       "Vungle.cs will create the VungleManager instance. A Vungle manager already exists in your scene. Please remove the script from the scene.");
     }
 }
Ejemplo n.º 26
0
    // Windows SDK calls this function
    public static void OnEvent(string sdkEvent, string arg)
    {
        switch (sdkEvent)
        {
        case "OnAdStart":
            // Placement
            if (OnAdStartEvent != null)
            {
                OnAdStartEvent(arg);
            }
            break;

        case "OnAdEnd":
            // CallToActionClicked:Placement:IsCompletedView:WatchedDuration(Milliseconds)
            if (OnAdFinishedEvent != null)
            {
                adWinFinishedEventArgs = new AdFinishedEventArgs();
                var args = arg.Split(new char[] { ':' });
                adWinFinishedEventArgs.WasCallToActionClicked = "1".Equals(args[0]);
                adWinFinishedEventArgs.IsCompletedView        = bool.Parse(args[2]);
                adWinFinishedEventArgs.TimeWatched            = double.Parse(args[3]) / 1000;
                OnAdFinishedEvent(args[1], adWinFinishedEventArgs);
            }
            break;

        case "OnAdPlayableChanged":
            // Playable(int):Placement
            if (OnAdPlayableEvent != null)
            {
                var args1 = arg.Split(new char[] { ':' });
                OnAdPlayableEvent(args1[1], "1".Equals(args1[0]));
            }
            break;

        case "Diagnostic":
            // LogMessage
            if (OnSDKLogEvent != null)
            {
                OnSDKLogEvent(arg);
            }
            break;

        case "OnInitCompleted":
            // InitializeSuccess(int)
            if (OnSDKInitializeEvent != null && "1".Equals(arg))
            {
                OnSDKInitializeEvent();
            }
            break;

        case "OnError":
            if (OnErrorEvent != null)
            {
                OnErrorEvent(arg);
            }
            break;

        case "OnWarning":
            if (OnWarningEvent != null)
            {
                OnWarningEvent(arg);
            }
            break;

        default:
            VungleLog.Log(VungleLog.Level.Error, VungleLog.Context.LogEvent, "OnEvent",
                          string.Format("nhandled SDK Event: {0}", sdkEvent));
            break;
        }
    }