/// <summary>
 /// Show Facebook rewarded video
 /// </summary>
 /// <param name="CompleteMethod">callback called when user closes the rewarded video -> if true video was not skipped</param>
 public void ShowRewardVideo(UnityAction <bool> CompleteMethod)
 {
     if (IsRewardVideoAvailable())
     {
         rewardedVideoisLoaded = false;
         triggerCompleteMethod = true;
         OnCompleteMethod      = CompleteMethod;
         rewardedVideoAd.Show();
     }
 }
 public void ShowRewardedVideo()
 {
     if (RewardedVideoAd.IsLoaded)
     {
         RewardedVideoAd.Show();
     }
 }
Exemple #3
0
 void ShowRV()
 {
     if (rewardedVideoAd != null && rewardedVideoAd.IsLoaded())
     {
         rewardedVideoAd.Show();
     }
 }
 void RewardedVideoAdDidLoad()
 {
     if (rewardedVideoAd.IsValid())
     {
         rewardedVideoAd.Show();
     }
     //Manager.LoadingAnimation(false);
 }
Exemple #5
0
    public void LoadRewardedVideo()
    {
        statusLabel.text = "Loading rewardedVideo ad...";
        rewardedVideoAd  = new RewardedVideoAd("378297562859739_378307472858748");
        rewardedVideoAd.Register(gameObject);
        rewardedVideoAd.RewardedVideoAdDidLoad = delegate()
        {
            Debug.Log("RewardedVideo ad loaded.");
            isLoaded = true;
            didClose = false;
            string isAdValid = rewardedVideoAd.IsValid() ? "valid" : "invalid";
            statusLabel.text = "Ad loaded and is " + isAdValid + ". Click show to present!";
            rewardedVideoAd.Show();
        };

        rewardedVideoAd.RewardedVideoAdDidFailWithError = delegate(string error)
        {
            Debug.Log("RewardedVideo ad failed to load with error: " + error);
            SetStatusOrderingWindow(false);
        };

        rewardedVideoAd.RewardedVideoAdWillLogImpression = delegate()
        {
            AdGetReward();
        };

        rewardedVideoAd.RewardedVideoAdDidClick = delegate()
        {
            AdGetReward();
        };

        rewardedVideoAd.RewardedVideoAdDidFail = delegate()
        {
            Debug.Log("Rewarded video ad not validated, or no response from server");
            SetStatusOrderingWindow(false);
        };

        rewardedVideoAd.RewardedVideoAdDidClose = delegate()
        {
            Debug.Log("Rewarded video ad did close.");
            didClose = true;
            SetStatusOrderingWindow(false);
        };

        if (Application.platform == RuntimePlatform.Android)
        {
            rewardedVideoAd.RewardedVideoAdActivityDestroyed = delegate()
            {
                if (!didClose)
                {
                    Debug.Log("Rewarded video activity destroyed without being closed first.");
                    Debug.Log("Game should resume. User should not get a reward.");
                }
            };
        }
        rewardedVideoAd.LoadAd();
    }
Exemple #6
0
 /// <summary>
 /// Ad loaded callback
 /// </summary>
 /// <param name="ad"></param>
 public void OnAdLoaded(IAd ad)
 {
     try
     {
         // Show the ad
         RewardVideoAd?.Show();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Exemple #7
0
 /// <summary>
 /// Ad loaded callback
 /// </summary>
 /// <param name="ad"></param>
 public void OnAdLoaded(IAd ad)
 {
     try
     {
         // Show the ad
         RewardVideoAd?.Show();
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
Exemple #8
0
 public void ShowRewardedVideo()
 {
     if (RewardedVideoAd.IsLoaded)
     {
         RewardedVideoAd.Show();
     }
     else
     {
         Toast.MakeText(this, "Ad not loaded. Check your internet connection", ToastLength.Long).Show();
         FinishGameAndShowAds();
     }
 }
Exemple #9
0
 // Show button
 public void ShowRewardedVideo()
 {
     if (isLoaded)
     {
         rewardedVideoAd.Show();
         isLoaded         = false;
         statusLabel.text = "";
     }
     else
     {
         statusLabel.text = "Ad not loaded. Click load to request an ad.";
     }
 }
Exemple #10
0
        public bool ShowRewardedVideo()
        {
            if (!isLoaded)
            {
                LoadRewardedVideo();
            }
            else
            {
                rewardedVideoAd.Show();
                AppsFlyerManager.Instance.TrackRewardVideoFacebookView();
                isLoaded = false;
                return(true);
            }

            return(false);
        }
Exemple #11
0
 public bool ShowRewardedAd()
 {
     if (isRewardedLoaded)
     {
         isRewardedLoaded = false;
         rewardedAd.Show();
         return(true);
     }
     else
     {
         if (isRewardedLoading == false)
         {
             LoadRewardedAd();
         }
         return(false);
     }
 }
Exemple #12
0
    public UniRx.IObservable <AdService.V2PShowResult> Show()
    {
        return(Observable.Return(AdService.V2PShowResult.Failed));

        if (adReady.Value)
        {
            return(Observable.Create(delegate(UniRx.IObserver <AdService.V2PShowResult> subscriber)
            {
                FacebookProvider facebookProvider = this;
                CompositeDisposable compositeDisposable = new CompositeDisposable();
                adFinished.ObserveOnMainThread().Take(1).Subscribe(delegate(bool success)
                {
                    subscriber.OnNext(success ? AdService.V2PShowResult.Finished : AdService.V2PShowResult.Failed);
                    subscriber.OnCompleted();
                })
                .AddTo(compositeDisposable);
                RewardedVideoAd rewardedVideoAd = ad;
                rewardedVideoAd.RewardedVideoAdDidFail = delegate
                {
                    facebookProvider.adFinished.OnNext(value: false);
                };
                rewardedVideoAd.RewardedVideoAdComplete = delegate
                {
                    facebookProvider.adFinished.OnNext(value: true);
                };
                rewardedVideoAd.RewardedVideoAdDidClose = delegate
                {
                    facebookProvider.adFinished.OnNext(value: false);
                };
                rewardedVideoAd.rewardedVideoAdActivityDestroyed = delegate
                {
                    facebookProvider.adFinished.OnNext(value: false);
                };
                ad = null;
                adReady.Value = false;
                if (!rewardedVideoAd.Show())
                {
                    adFinished.OnNext(value: false);
                }
                return compositeDisposable;
            }));
        }
        return(Observable.Return(AdService.V2PShowResult.Failed));
    }
    void LoadRewardedVideo()
    {
        rewardedVideoAd = new RewardedVideoAd(PLACEMENT_ID);

        rewardedVideoAd.Register(gameObject);

        rewardedVideoAd.RewardedVideoAdDidLoad = delegate
        {
            PlatformInterface.instance.logger.Log("RewardedVideo ad loaded.");
            IsLoaded = true;
            didClose = false;
            //showAfterLoaded
            if (IsAdCurrentlyCalled)
            {
                Show();
            }
        };

        rewardedVideoAd.RewardedVideoAdDidFailWithError = delegate(string error)
        {
            PlatformInterface.instance.logger.Log("RewardedVideo ad failed to load with error: " + error);
            platformFacebookAds.HandleShowResult(false, error);
        };

        rewardedVideoAd.RewardedVideoAdWillLogImpression = delegate
        {
            PlatformInterface.instance.logger.Log("RewardedVideo ad logged impression.");
        };

        rewardedVideoAd.RewardedVideoAdDidClick = delegate
        {
            PlatformInterface.instance.logger.Log("RewardedVideo ad clicked.");
        };

        rewardedVideoAd.RewardedVideoAdDidSucceed = delegate
        {
            PlatformInterface.instance.logger.Log("Rewarded video ad validated by server");
            // 검증 로직 없을 때는 불리지 않는 듯 하다.
        };

        rewardedVideoAd.RewardedVideoAdDidFail = delegate
        {
            PlatformInterface.instance.logger.Log("Rewarded video ad not validated, or no response from server");
            platformFacebookAds.HandleShowResult(false, "DidFail");
        };

        rewardedVideoAd.RewardedVideoAdComplete = delegate
        {
            PlatformInterface.instance.logger.Log("Rewarded video ad completed");
            didCompleted = true;
        };

        rewardedVideoAd.RewardedVideoAdDidClose = delegate
        {
            PlatformInterface.instance.logger.Log("Rewarded video ad did close.");
            didClose = true;
            platformFacebookAds.HandleShowResult(didCompleted, "");
            rewardedVideoAd?.Dispose();
        };

        if (Application.platform == RuntimePlatform.Android) /*
                                                              * Only relevant to Android.
                                                              * This callback will only be triggered if the Rewarded Video activity
                                                              * has been destroyed without being properly closed. This can happen if
                                                              * an app with launchMode:singleTask (such as a Unity game) goes to
                                                              * background and is then relaunched by tapping the icon.
                                                              */
        {
            rewardedVideoAd.RewardedVideoAdActivityDestroyed = () =>
            {
                if (!didClose)
                {
                    PlatformInterface.instance.logger.Log(
                        "Rewarded video activity destroyed without being closed first.");
                    PlatformInterface.instance.logger.Log("Game should resume. User should not get a reward.");
                    platformFacebookAds.HandleShowResult(false, "ActivityDestroyed");
                }
            }
        }
        ;

        // Initiate the request to load the ad.
        rewardedVideoAd.LoadAd();
    }

    void Show()
    {
        if (IsLoaded)
        {
            didCompleted = false;
            rewardedVideoAd.Show();
            IsLoaded = false;
        }
    }

    void OnDestroy()
    {
        // Dispose of rewardedVideo ad when the scene is destroyed
        rewardedVideoAd?.Dispose();
        PlatformInterface.instance.logger.Log("RewardedVideoAdTest was destroyed!");
    }
}
 protected override bool DoShowAd()
 {
     m_RewardVideoAd.Show();
     return(true);
 }