Esempio n. 1
0
        public override int Create(string placementId, RewardData rewardData,
                                   RewardedVideoAd rewardedVideoAd)
        {
            int uniqueId = 0;

            if (rewardData != null)
            {
                uniqueId = RewardedVideoAdBridgeIOS.FBRewardedVideoAdBridgeCreateWithReward(placementId, rewardData.UserId, rewardData.Currency);
            }
            else
            {
                uniqueId = RewardedVideoAdBridgeIOS.FBRewardedVideoAdBridgeCreate(placementId);
            }

            RewardedVideoAdBridgeIOS.rewardedVideoAds.Add(uniqueId, new RewardedVideoAdContainer(rewardedVideoAd));
            RewardedVideoAdBridgeIOS.FBRewardedVideoAdBridgeOnLoad(uniqueId, rewardedVideoAdDidLoadBridgeCallback);
            RewardedVideoAdBridgeIOS.FBRewardedVideoAdBridgeOnImpression(uniqueId, rewardedVideoAdWillLogImpressionBridgeCallback);
            RewardedVideoAdBridgeIOS.FBRewardedVideoAdBridgeOnClick(uniqueId, rewardedVideoAdDidClickBridgeCallback);
            RewardedVideoAdBridgeIOS.FBRewardedVideoAdBridgeOnError(uniqueId, rewardedVideoAdDidFailWithErrorBridgeCallback);
            RewardedVideoAdBridgeIOS.FBRewardedVideoAdBridgeOnDidClose(uniqueId, rewardedVideoAdDidCloseBridgeCallback);
            RewardedVideoAdBridgeIOS.FBRewardedVideoAdBridgeOnWillClose(uniqueId, rewardedVideoAdWillCloseBridgeCallback);
            RewardedVideoAdBridgeIOS.FBRewardedVideoAdBridgeOnVideoComplete(uniqueId, rewardedVideoAdCompleteBridgeCallback);
            RewardedVideoAdBridgeIOS.FBRewardedVideoAdBridgeOnServerRewardSuccess(uniqueId, rewardedVideoAdDidSucceedBridgeCallback);
            RewardedVideoAdBridgeIOS.FBRewardedVideoAdBridgeOnServerRewardFailure(uniqueId, rewardedVideoAdDidFailBridgeCallback);

            return(uniqueId);
        }
Esempio n. 2
0
#pragma warning restore 0414

        public RewardedVideoAdBridgeListenerProxy(RewardedVideoAd rewardedVideoAd,
                                                  AndroidJavaObject bridgedRewardedVideoAd)
            : base("com.facebook.ads.S2SRewardedVideoAdExtendedListener")
        {
            this.rewardedVideoAd        = rewardedVideoAd;
            this.bridgedRewardedVideoAd = bridgedRewardedVideoAd;
        }
Esempio n. 3
0
        public override int Create(string placementId, RewardData rewardData,
                                   RewardedVideoAd rewardedVideoAd)
        {
            AdUtility.Prepare();
            AndroidJavaClass  unityPlayer     = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject currentActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            AndroidJavaObject context         = currentActivity.Call <AndroidJavaObject>("getApplicationContext");

            AndroidJavaObject bridgedRewardedVideoAd = new AndroidJavaObject("com.facebook.ads.RewardedVideoAd", context, placementId);

            RewardedVideoAdBridgeListenerProxy proxy = new RewardedVideoAdBridgeListenerProxy(rewardedVideoAd, bridgedRewardedVideoAd);

            bridgedRewardedVideoAd.Call("setAdListener", proxy);

            if (rewardData != null)
            {
                AndroidJavaObject rewardDataObj = new AndroidJavaObject("com.facebook.ads.RewardData", rewardData.UserId, rewardData.Currency);
                bridgedRewardedVideoAd.Call("setRewardData", rewardDataObj);
            }

            RewardedVideoAdContainer rewardedVideoAdContainer = new RewardedVideoAdContainer(rewardedVideoAd)
            {
                bridgedRewardedVideoAd = bridgedRewardedVideoAd,
                listenerProxy          = proxy
            };

            int key = RewardedVideoAdBridgeAndroid.lastKey;

            RewardedVideoAdBridgeAndroid.rewardedVideoAds.Add(key, rewardedVideoAdContainer);
            RewardedVideoAdBridgeAndroid.lastKey++;
            return(key);
        }
Esempio n. 4
0
        public override int Create(string placementId, RewardData rewardData, RewardedVideoAd rewardedVideoAd)
        {
            AdUtility.prepare();
            AndroidJavaClass  class2 = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject obj3   = class2.GetStatic <AndroidJavaObject>("currentActivity").Call <AndroidJavaObject>("getApplicationContext", new object[0]);

            object[]          args = new object[] { obj3, placementId };
            AndroidJavaObject bridgedRewardedVideoAd = new AndroidJavaObject("com.facebook.ads.RewardedVideoAd", args);
            RewardedVideoAdBridgeListenerProxy proxy = new RewardedVideoAdBridgeListenerProxy(rewardedVideoAd, bridgedRewardedVideoAd);

            object[] objArray2 = new object[] { proxy };
            bridgedRewardedVideoAd.Call("setAdListener", objArray2);
            if (rewardData != null)
            {
                object[]          objArray3 = new object[] { rewardData.UserId, rewardData.Currency };
                AndroidJavaObject obj5      = new AndroidJavaObject("com.facebook.ads.RewardData", objArray3);
                object[]          objArray4 = new object[] { obj5 };
                bridgedRewardedVideoAd.Call("setRewardData", objArray4);
            }
            RewardedVideoAdContainer container = new RewardedVideoAdContainer(rewardedVideoAd)
            {
                bridgedRewardedVideoAd = bridgedRewardedVideoAd,
                listenerProxy          = proxy
            };
            int lastKey = RewardedVideoAdBridgeAndroid.lastKey;

            rewardedVideoAds.Add(lastKey, container);
            RewardedVideoAdBridgeAndroid.lastKey++;
            return(lastKey);
        }
        public override int Create(string placementId, RewardData rewardData, RewardedVideoAd rewardedVideoAd)
        {
            AdUtility.prepare();
            AndroidJavaClass  androidJavaClass   = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject @static            = androidJavaClass.GetStatic <AndroidJavaObject>("currentActivity");
            AndroidJavaObject androidJavaObject  = @static.Call <AndroidJavaObject>("getApplicationContext", new object[0]);
            AndroidJavaObject androidJavaObject2 = new AndroidJavaObject("com.facebook.ads.RewardedVideoAd", androidJavaObject, placementId);
            RewardedVideoAdBridgeListenerProxy rewardedVideoAdBridgeListenerProxy = new RewardedVideoAdBridgeListenerProxy(rewardedVideoAd, androidJavaObject2);

            androidJavaObject2.Call("setAdListener", rewardedVideoAdBridgeListenerProxy);
            if (rewardData != null)
            {
                AndroidJavaObject androidJavaObject3 = new AndroidJavaObject("com.facebook.ads.RewardData", rewardData.UserId, rewardData.Currency);
                androidJavaObject2.Call("setRewardData", androidJavaObject3);
            }
            RewardedVideoAdContainer rewardedVideoAdContainer = new RewardedVideoAdContainer(rewardedVideoAd);

            rewardedVideoAdContainer.bridgedRewardedVideoAd = androidJavaObject2;
            rewardedVideoAdContainer.listenerProxy          = rewardedVideoAdBridgeListenerProxy;
            int num = lastKey;

            rewardedVideoAds.Add(num, rewardedVideoAdContainer);
            lastKey++;
            return(num);
        }
Esempio n. 6
0
        private void LoadAd()
        {
            rewarded_video = new AudienceNetwork.RewardedVideoAd("445801979415468_445805622748437");
            rewarded_video.Register(game_object);
            rewarded_video.RewardedVideoAdDidLoad = () =>
            {
                is_loaded = true;
            };

            rewarded_video.RewardedVideoAdDidFailWithError = (string error) =>
            {
                Debug.LogError(error);
            };

            rewarded_video.RewardedVideoAdWillLogImpression = (delegate() {
                Debug.Log("RewardedVideo ad logged impression.");
                complete = true;
            });

            rewarded_video.RewardedVideoAdDidClick = (delegate() {
                Debug.Log("RewardedVideo ad clicked.");
                complete = true;
            });

            rewarded_video.RewardedVideoAdDidClose = (delegate() {
                Debug.Log("Rewarded video ad did close.");
                complete = true;
                reward = true;
                did_close = true;
                if (null != rewarded_video)
                {
                    rewarded_video.Dispose();
                    rewarded_video = null;
                }
            });

#if UNITY_ANDROID
            /*
             * Android에만 적용됩니다.
             * 보상형 동영상 활동이 적절히 닫히지 않은 상태에서
             * 폐기되었을 경우에만 이 콜백이 트리거됩니다.  launchMode:singleTask가 있는 앱(예: Unity 게임)을
             * 백그라운드로 돌렸다가 아이콘을 탭해서 다시 시작하면 이렇게 될 수 있습니다.
             */
            rewarded_video.rewardedVideoAdActivityDestroyed = (delegate()
            {
                if (false == did_close)
                {
                    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.
            rewarded_video.LoadAd();
        }
 internal RewardedVideoAdContainer(RewardedVideoAd rewardedVideoAd)
 {
     this.rewardedVideoAd = rewardedVideoAd;
 }
Esempio n. 8
0
 public virtual int Create(string placementId, RewardData rewardData,
                           RewardedVideoAd RewardedVideoAd)
 {
     return(123);
 }
Esempio n. 9
0
 public virtual int Create(string placementId, RewardData rewardData, RewardedVideoAd RewardedVideoAd) =>
 0x7b;