Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
        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);
        }