public void Reward(RewardDelegate rewardDelegate, string placementId) { if (string.IsNullOrEmpty(placementId)) { rewardDelegate(new RewardResult(RewardResult.Type.LoadFailed, "FAN: Placement ID is empty")); } if (rewardedVideoAd != null) { rewardedVideoAd.Dispose(); } Manager.LoadingAnimation(true); onRewardWatched = rewardDelegate; rewardedVideoAd = new RewardedVideoAd(placementId); rewardedVideoAd.Register(gameObject); rewardedVideoAd.RewardedVideoAdDidLoad = RewardedVideoAdDidLoad; rewardedVideoAd.RewardedVideoAdDidFailWithError = RewardedVideoAdDidFailWithError; //rewardedVideoAd.RewardedVideoAdWillLogImpression //rewardedVideoAd.RewardedVideoAdDidClick rewardedVideoAd.RewardedVideoAdDidSucceed = RewardedVideoAdDidSucceed; rewardedVideoAd.RewardedVideoAdDidFail = RewardedVideoAdDidFail; rewardedVideoAd.RewardedVideoAdDidClose = RewardedVideoAdDidClose; #if UNITY_ANDROID //rewardedVideoAd.RewardedVideoAdActivityDestroyed #endif rewardedVideoAd.LoadAd(); }
private void SetStatusOrderingWindow(bool status) { if (!status && rewardedVideoAd != null) { rewardedVideoAd.Dispose(); } window_ordering.SetActive(status); }
private void OnDestroy() { if (rewardedVideoAd != null) { rewardedVideoAd.Dispose(); } UnityEngine.Debug.Log("RewardedVideoAdTest was destroyed!"); }
void OnDestroy() { // Dispose of rewardedVideo ad when the scene is destroyed if (rewardedVideoAd != null) { rewardedVideoAd.Dispose(); } Debug.Log("RewardedVideoAdTest was destroyed!"); }
void ShowRewardedVideoAd(UIAlertAction obj) { rewardedVideoAd?.Dispose(); rewardedVideoAd = null; rewardedVideoAd = new RewardedVideoAd(AdPlacementIds.RewardedVideo) { Delegate = this }; rewardedVideoAd.LoadAd(); }
protected override void DoCleanAd() { if (m_RewardVideoAd == null) { return; } //#if UNITY_IOS m_RewardVideoAd.Dispose(); m_RewardVideoAd = null; //#endif }
private void RewardedAdCompleted() { isRewardedLoading = false; isRewardedLoaded = false; if (rewardedAd != null) { rewardedAd.Dispose(); } LoadRewardedAd(); AdvertEngine.Instance.RewardedVideoResult(AdResult.COMPLETED); }
/// <summary> /// Load a Facebook rewarded video and add the required listeners /// </summary> private void LoadRewardedVideo() { if (rewardedVideoAd != null) { rewardedVideoAd.Dispose(); } rewardedVideoAd = new RewardedVideoAd(rewardedVideoId); rewardedVideoAd.Register(gameObject); rewardedVideoAd.RewardedVideoAdDidLoad += RewardedVideoLoaded; rewardedVideoAd.RewardedVideoAdDidFailWithError += RewardedVideoFailed; rewardedVideoAd.RewardedVideoAdWillLogImpression += RewardedVideoAdWillLogImpression; rewardedVideoAd.RewardedVideoAdDidClick += RewardedVideoAdDidClick; rewardedVideoAd.RewardedVideoAdComplete += RewardedVideoWatched; rewardedVideoAd.RewardedVideoAdDidClose += RewardedVideoAdClosed; #if UNITY_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 = delegate() { if (!rewardedVideoDidClose) { Debug.Log("Rewarded video activity destroyed without being closed first."); Debug.Log("Game should resume. User should not get a reward."); RewardedVideoAdClosed(); } }; #endif rewardedVideoAd.LoadAd(); }
private void RequestNewAd() { return; if (ad != null) { ad.Dispose(); } ad = new RewardedVideoAd(Zone); ad.Register(listener); ad.RewardedVideoAdDidLoad = delegate { _loadingEvents.OnNext(value: true); }; ad.RewardedVideoAdDidFailWithError = delegate { _loadingEvents.OnNext(value: false); }; Loading.Value = true; adReady.Value = false; ad.LoadAd(); }
// Load button public void LoadRewardedVideo() { statusLabel.text = "Loading rewardedVideo ad..."; // Create the rewarded video unit with a placement ID (generate your own on the Facebook app settings). // Use different ID for each ad placement in your app. rewardedVideoAd = new RewardedVideoAd("1091882857878164_1152806438452472"); // For S2S validation you can create the rewarded video ad with the reward data // Refer to documentation here: // https://developers.facebook.com/docs/audience-network/android/rewarded-video#server-side-reward-validation // https://developers.facebook.com/docs/audience-network/ios/rewarded-video#server-side-reward-validation RewardData rewardData = new RewardData { UserId = "USER_ID", Currency = "REWARD_ID" }; #pragma warning disable 0219 RewardedVideoAd s2sRewardedVideoAd = new RewardedVideoAd("1091882857878164_1152806438452472", rewardData); #pragma warning restore 0219 rewardedVideoAd.Register(gameObject); // Set delegates to get notified on changes or when the user interacts with the ad. 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.RewardedVideoAdDidFailWithError = delegate(string error) { Debug.Log("RewardedVideo ad failed to load with error: " + error); statusLabel.text = "RewardedVideo ad failed to load. Check console for details."; }; rewardedVideoAd.RewardedVideoAdWillLogImpression = delegate() { Debug.Log("RewardedVideo ad logged impression."); }; rewardedVideoAd.RewardedVideoAdDidClick = delegate() { Debug.Log("RewardedVideo ad clicked."); }; // For S2S validation you need to register the following two callback // Refer to documentation here: // https://developers.facebook.com/docs/audience-network/android/rewarded-video#server-side-reward-validation // https://developers.facebook.com/docs/audience-network/ios/rewarded-video#server-side-reward-validation rewardedVideoAd.RewardedVideoAdDidSucceed = delegate() { Debug.Log("Rewarded video ad validated by server"); }; rewardedVideoAd.RewardedVideoAdDidFail = delegate() { Debug.Log("Rewarded video ad not validated, or no response from server"); }; rewardedVideoAd.RewardedVideoAdDidClose = delegate() { Debug.Log("Rewarded video ad did close."); didClose = true; if (rewardedVideoAd != null) { rewardedVideoAd.Dispose(); } }; #if UNITY_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 = delegate() { if (!didClose) { Debug.Log("Rewarded video activity destroyed without being closed first."); Debug.Log("Game should resume. User should not get a reward."); } }; #endif // Initiate the request to load the ad. rewardedVideoAd.LoadAd(); }
private void LoadRewardedVideo() { #if UNITY_ANDROID var videoId = GameConfig.Instance.FbAds.androidRewardedVideo.Trim(); #elif UNITY_IPHONE var videoId = GameConfig.Instance.FbAds.iOSRewardedVideo.Trim(); #endif RewardData rewardData = new RewardData(); rewardData.UserId = "USER_ID"; rewardData.Currency = "REWARD_ID"; rewardedVideoAd = Testing ? new RewardedVideoAd("VID_HD_16_9_15S_APP_INSTALL#2025198837536206_2115449855177770", rewardData) : new RewardedVideoAd(videoId, rewardData); rewardedVideoAd.Register(gameObject); // Set delegates to get notified on changes or when the user interacts with the ad. rewardedVideoAd.RewardedVideoAdDidLoad = (delegate() { // Debug.Log("RewardedVideo ad loaded."); isLoaded = true; }); rewardedVideoAd.RewardedVideoAdDidFailWithError = (delegate(string error) { // Debug.Log("RewardedVideo ad failed to load with error: " + error); }); rewardedVideoAd.RewardedVideoAdWillLogImpression = (delegate() { // Debug.Log("RewardedVideo ad logged impression."); }); rewardedVideoAd.RewardedVideoAdDidClick = (delegate() { // Debug.Log("RewardedVideo ad clicked."); }); rewardedVideoAd.RewardedVideoAdDidClose = (delegate() { didClose = true; if (rewardedVideoAd != null) { rewardedVideoAd.Dispose(); } }); rewardedVideoAd.RewardedVideoAdDidSucceed = (delegate() // for finished video { GamePlay.Instance.AfterVideoAds(); }); rewardedVideoAd.RewardedVideoAdDidFail = (delegate() // for fail finished { GameOver.Instance.OnCancel(); }); rewardedVideoAd.rewardedVideoAdActivityDestroyed = (delegate() { if (!didClose) { GameOver.Instance.OnCancel(); } }); rewardedVideoAd.LoadAd(); }
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!"); } }