コード例 #1
0
        public override int Create(string placementId,
                                   AdView adView,
                                   AdSize size)
        {
            AdUtility.prepare();
            AndroidJavaClass  unityPlayer     = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject currentActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            AndroidJavaObject context         = currentActivity.Call <AndroidJavaObject>("getApplicationContext");

            AndroidJavaObject bridgedAdView = new AndroidJavaObject("com.facebook.ads.AdView",
                                                                    context,
                                                                    placementId,
                                                                    javaAdSizeFromAdSize(size));

            AdViewBridgeListenerProxy proxy = new AdViewBridgeListenerProxy(adView, bridgedAdView);

            bridgedAdView.Call("setAdListener", proxy);

            AdViewContainer adViewContainer = new AdViewContainer(adView);

            adViewContainer.bridgedAdView = bridgedAdView;
            adViewContainer.listenerProxy = proxy;

            int key = AdViewBridgeAndroid.lastKey;

            AdViewBridgeAndroid.adViews.Add(key, adViewContainer);
            AdViewBridgeAndroid.lastKey++;
            return(key);
        }
コード例 #2
0
        private static void adViewDidFinishClickBridgeCallback(int uniqueId)
        {
            AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId);

            if (container && container.onFinishedClick != null)
            {
                container.onFinishedClick();
            }
        }
コード例 #3
0
        private static void adViewDidFailWithErrorBridgeCallback(int uniqueId, string error)
        {
            AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId);

            if (container && container.onError != null)
            {
                container.onError(error);
            }
        }
コード例 #4
0
        private static void adViewWillLogImpressionBridgeCallback(int uniqueId)
        {
            AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId);

            if (container && container.onImpression != null)
            {
                container.onImpression();
            }
        }
コード例 #5
0
        private static void adViewDidLoadBridgeCallback(int uniqueId)
        {
            AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId);

            if (container && container.onLoad != null)
            {
                container.onLoad();
            }
        }
コード例 #6
0
        public override void OnFinishedClick(int uniqueId,
                                             FBAdViewBridgeCallback callback)
        {
            AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId);

            if (container)
            {
                container.onFinishedClick = callback;
            }
        }
コード例 #7
0
        public override void OnError(int uniqueId,
                                     FBAdViewBridgeErrorCallback callback)
        {
            AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId);

            if (container)
            {
                container.onError = callback;
            }
        }
コード例 #8
0
        public override void OnImpression(int uniqueId,
                                          FBAdViewBridgeCallback callback)
        {
            AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId);

            if (container)
            {
                container.onImpression = callback;
            }
        }
コード例 #9
0
        // Sets up internal managed callbacks

        public override void OnLoad(int uniqueId,
                                    FBAdViewBridgeCallback callback)
        {
            AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId);

            if (container)
            {
                container.onLoad = (container.adView.LoadAdFromData);
            }
        }
コード例 #10
0
        private AndroidJavaObject adViewForAdViewId(int uniqueId)
        {
            AdViewContainer value = null;

            if (adViews.TryGetValue(uniqueId, out value))
            {
                return(value.bridgedAdView);
            }
            return(null);
        }
コード例 #11
0
        public override int Load(int uniqueId, String bidPayload)
        {
            AdUtility.Prepare();
            AdViewContainer adViewContainer = AdViewContainerForAdViewId(uniqueId);

            if (adViewContainer != null)
            {
                adViewContainer.Load(bidPayload);
            }
            return(uniqueId);
        }
コード例 #12
0
        private static AdViewContainer adViewContainerForAdViewId(int uniqueId)
        {
            AdViewContainer adView  = null;
            bool            success = AdViewBridgeIOS.adViews.TryGetValue(uniqueId, out adView);

            if (success)
            {
                return(adView);
            }
            else
            {
                return(null);
            }
        }
コード例 #13
0
        private AndroidJavaObject adViewForAdViewId(int uniqueId)
        {
            AdViewContainer adViewContainer = null;
            bool            success         = AdViewBridgeAndroid.adViews.TryGetValue(uniqueId, out adViewContainer);

            if (success)
            {
                return(adViewContainer.bridgedAdView);
            }
            else
            {
                return(null);
            }
        }
コード例 #14
0
        public override int Create(string placementId, AdView adView, AdSize size)
        {
            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.AdView", androidJavaObject, placementId, javaAdSizeFromAdSize(size));
            AdViewBridgeListenerProxy adViewBridgeListenerProxy = new AdViewBridgeListenerProxy(adView, androidJavaObject2);

            androidJavaObject2.Call("setAdListener", adViewBridgeListenerProxy);
            AdViewContainer adViewContainer = new AdViewContainer(adView);

            adViewContainer.bridgedAdView = androidJavaObject2;
            adViewContainer.listenerProxy = adViewBridgeListenerProxy;
            int num = lastKey;

            adViews.Add(num, adViewContainer);
            lastKey++;
            return(num);
        }
コード例 #15
0
        public override int Create(string placementId, AdView adView, AdSize size)
        {
            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, this.javaAdSizeFromAdSize(size) };
            AndroidJavaObject         bridgedAdView = new AndroidJavaObject("com.facebook.ads.AdView", args);
            AdViewBridgeListenerProxy proxy         = new AdViewBridgeListenerProxy(adView, bridgedAdView);

            object[] objArray2 = new object[] { proxy };
            bridgedAdView.Call("setAdListener", objArray2);
            AdViewContainer container = new AdViewContainer(adView)
            {
                bridgedAdView = bridgedAdView,
                listenerProxy = proxy
            };
            int lastKey = AdViewBridgeAndroid.lastKey;

            adViews.Add(lastKey, container);
            AdViewBridgeAndroid.lastKey++;
            return(lastKey);
        }
コード例 #16
0
        public override int Create (string placementId,
                                    AdView adView,
                                    AdSize size)
        {
            AdUtility.prepare ();
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
            AndroidJavaObject context = currentActivity.Call<AndroidJavaObject>("getApplicationContext");

            AndroidJavaObject bridgedAdView = new AndroidJavaObject("com.facebook.ads.AdView",
                                                                    context,
                                                                    placementId,
                                                                    javaAdSizeFromAdSize (size));

            AdViewBridgeListenerProxy proxy = new AdViewBridgeListenerProxy (adView, bridgedAdView);
            bridgedAdView.Call ("setAdListener", proxy);

            AdViewBridgeImpressionListenerProxy impressionListenerProxy = new AdViewBridgeImpressionListenerProxy (adView, bridgedAdView);
            bridgedAdView.Call ("setImpressionListener", impressionListenerProxy);

            AdViewContainer adViewContainer = new AdViewContainer (adView);
            adViewContainer.bridgedAdView = bridgedAdView;
            adViewContainer.listenerProxy = proxy;
            adViewContainer.impressionListenerProxy = impressionListenerProxy;

            int key = AdViewBridgeAndroid.lastKey;
            AdViewBridgeAndroid.adViews.Add(key, adViewContainer);
            AdViewBridgeAndroid.lastKey++;
            return key;
        }