public void LoadRewardedVideoAd() { RewardedVideoAd.LoadAd("ca-app-pub-8211072909515345/2330386383", new AdRequest.Builder().Build()); //RewardedVideoAd.LoadAd("ca-app-pub-3940256099942544/5224354917", //new AdRequest.Builder().AddTestDevice("FE5692B3DAD1B4CE3BE3BDA2FF4B6103").Build()); }
public static RewardedVideoAd InitRewardVideo(Activity activity) { try { var isPro = ListUtils.MyUserInfoList.FirstOrDefault()?.IsPro ?? 0; if (isPro == 0 && AppSettings.ShowFbRewardVideoAds) { if (CountRewarded == AppSettings.ShowAdMobRewardedVideoCount) { InitializeFacebook.Initialize(activity); CountRewarded = 0; var rewardVideoAd = new RewardedVideoAd(activity, AppSettings.AdsFbRewardVideoKey); rewardVideoAd.SetAdListener(new MyRRewardVideoAdListener(activity, rewardVideoAd)); rewardVideoAd.LoadAd(); //RewardVideoAd.SetRewardData(new RewardData("YOUR_USER_ID", "YOUR_REWARD")); return(rewardVideoAd); } CountRewarded++; } return(null); } catch (Exception e) { Console.WriteLine(e); return(null); } }
public static RewardedVideoAd InitRewardVideo(Activity activity) { try { if (AppSettings.ShowFbRewardVideoAds) { if (CountRewarded == AppSettings.ShowAdMobRewardedVideoCount) { InitializeFacebook.Initialize(activity); CountRewarded = 0; var rewardVideoAd = new RewardedVideoAd(activity, AppSettings.AdsFbRewardVideoKey); #pragma warning disable 618 rewardVideoAd.SetAdListener(new MyRRewardVideoAdListener(activity, rewardVideoAd)); #pragma warning restore 618 rewardVideoAd.LoadAd(); //RewardVideoAd.SetRewardData(new RewardData("YOUR_USER_ID", "YOUR_REWARD")); return(rewardVideoAd); } CountRewarded++; } return(null !); } catch (Exception e) { Methods.DisplayReportResultTrack(e); return(null !); } }
public void LoadRewardedAd() { if (isRewardedLoaded) { return; } if (isRewardedLoading) { return; } isRewardedLoading = true; isRewardedLoaded = false; rewardedAd = new RewardedVideoAd(rewardedAdId); rewardedAd.Register(gameObject); rewardedAd.RewardedVideoAdDidLoad = delegate() { LoadingRewardedAdSuccessful(); }; rewardedAd.RewardedVideoAdDidFailWithError = delegate(string error) { LoadingRewardedAdFaild(); }; rewardedAd.rewardedVideoAdComplete = delegate() { RewardedAdCompleted(); }; rewardedAd.LoadAd(); }
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(); }
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(); }
void ShowRewardedVideoAd(UIAlertAction obj) { rewardedVideoAd?.Dispose(); rewardedVideoAd = null; rewardedVideoAd = new RewardedVideoAd(AdPlacementIds.RewardedVideo) { Delegate = this }; rewardedVideoAd.LoadAd(); }
public void RequestRewardedVideo() { rewardedVideoAd = new RewardedVideoAd(rewardedVideoId); rewardedVideoAd.OnAdRewardActionCompleted += this.HandleRewardActionCompleted; rewardedVideoAd.LoadAd(); if (this.rewardedVideoAd.isReady() && statusAds) { this.rewardedVideoAd.Show(); } }
public void LoadRewardedVideoAd() { lock (_lock) { if (!_isRewardedVideoLoading && !RewardedVideoAd.IsLoaded) { _isRewardedVideoLoading = true; Bundle extras = new Bundle(); extras.PutBoolean("_noRefresh", true); var adMobAdapter = new AdMobAdapter(); AdRequest adRequest = new AdRequest.Builder() //.AddTestDevice(AdRequest.DeviceIdEmulator) //.AddTestDevice("FE5692B3DAD1B4CE3BE3BDA2FF4B6103") //.AddNetworkExtrasBundle(adMobAdapter.Class, extras) .Build(); RewardedVideoAd.UserId = "pub-74XXXXXXXXXXXXXX"; RewardedVideoAd.LoadAd(AD_UNIT_ID, adRequest); } } }
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(); }
/// <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(); }
protected override bool DoPreLoadAd() { if (m_RewardVideoAd != null && m_RewardVideoAd.IsValid()) { return(false); } if (m_RewardVideoAd == null) { m_RewardVideoAd = new RewardedVideoAd(m_Config.unitID); m_RewardVideoAd.Register(UIMgr.S.uiRoot.gameObject); m_RewardVideoAd.RewardedVideoAdDidLoad = HandleOnAdLoaded; m_RewardVideoAd.RewardedVideoAdDidFailWithError += HandleOnAdFailedToLoad; m_RewardVideoAd.RewardedVideoAdWillLogImpression += HandleOnAdLogImpression; m_RewardVideoAd.RewardedVideoAdDidClick += HandleOnAdClick; m_RewardVideoAd.RewardedVideoAdDidClose += HandleOnFBAdClose; m_RewardVideoAd.RewardedVideoAdComplete += HandleOnAdComplate; m_RewardVideoAd.RewardedVideoAdDidSucceed += HandleOnAdSuccess; } m_RewardVideoAd.LoadAd(); return(true); }
// 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!"); } }