public override int Create(string placementId,
                                   InterstitialAd interstitialAd)
        {
            AdUtility.Prepare();
            AndroidJavaClass  unityPlayer           = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject currentActivity       = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            AndroidJavaObject context               = currentActivity.Call <AndroidJavaObject>("getApplicationContext");
            AndroidJavaObject bridgedInterstitialAd = new AndroidJavaObject("com.facebook.ads.InterstitialAd", context, placementId);

            InterstitialAdBridgeListenerProxy proxy = new InterstitialAdBridgeListenerProxy(interstitialAd, bridgedInterstitialAd);

            bridgedInterstitialAd.Call("setAdListener", proxy);

            InterstitialAdContainer interstitialAdContainer = new InterstitialAdContainer(interstitialAd)
            {
                bridgedInterstitialAd = bridgedInterstitialAd,
                listenerProxy         = proxy
            };

            int key = InterstitialAdBridgeAndroid.lastKey;

            InterstitialAdBridgeAndroid.interstitialAds.Add(key, interstitialAdContainer);
            InterstitialAdBridgeAndroid.lastKey++;
            return(key);
        }
예제 #2
0
        public override int Create(string placementId, InterstitialAd interstitialAd)
        {
            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.InterstitialAd", androidJavaObject, placementId);
            InterstitialAdBridgeListenerProxy interstitialAdBridgeListenerProxy = new InterstitialAdBridgeListenerProxy(interstitialAd, androidJavaObject2);

            androidJavaObject2.Call("setAdListener", interstitialAdBridgeListenerProxy);
            InterstitialAdContainer interstitialAdContainer = new InterstitialAdContainer(interstitialAd);

            interstitialAdContainer.bridgedInterstitialAd = androidJavaObject2;
            interstitialAdContainer.listenerProxy         = interstitialAdBridgeListenerProxy;
            int num = lastKey;

            interstitialAds.Add(num, interstitialAdContainer);
            lastKey++;
            return(num);
        }
        public override int Create(string placementId, InterstitialAd interstitialAd)
        {
            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 bridgedInterstitialAd = new AndroidJavaObject("com.facebook.ads.InterstitialAd", args);
            InterstitialAdBridgeListenerProxy proxy = new InterstitialAdBridgeListenerProxy(interstitialAd, bridgedInterstitialAd);

            object[] objArray2 = new object[] { proxy };
            bridgedInterstitialAd.Call("setAdListener", objArray2);
            InterstitialAdContainer container = new InterstitialAdContainer(interstitialAd)
            {
                bridgedInterstitialAd = bridgedInterstitialAd,
                listenerProxy         = proxy
            };
            int lastKey = InterstitialAdBridgeAndroid.lastKey;

            interstitialAds.Add(lastKey, container);
            InterstitialAdBridgeAndroid.lastKey++;
            return(lastKey);
        }
        public override int Create (string placementId,
                                    InterstitialAd interstitialAd)
        {
            AdUtility.prepare ();
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
            AndroidJavaObject context = currentActivity.Call<AndroidJavaObject>("getApplicationContext");

            AndroidJavaObject bridgedInterstitialAd = new AndroidJavaObject("com.facebook.ads.InterstitialAd", context, placementId);

            InterstitialAdBridgeListenerProxy proxy = new InterstitialAdBridgeListenerProxy (interstitialAd, bridgedInterstitialAd);
            bridgedInterstitialAd.Call ("setAdListener", proxy);

            InterstitialAdBridgeImpressionListenerProxy impressionListenerProxy = new InterstitialAdBridgeImpressionListenerProxy (interstitialAd, bridgedInterstitialAd);
            bridgedInterstitialAd.Call ("setImpressionListener", impressionListenerProxy);

            InterstitialAdContainer interstitialAdContainer = new InterstitialAdContainer (interstitialAd);
            interstitialAdContainer.bridgedInterstitialAd = bridgedInterstitialAd;
            interstitialAdContainer.listenerProxy = proxy;
            interstitialAdContainer.impressionListenerProxy = impressionListenerProxy;

            int key = InterstitialAdBridgeAndroid.lastKey;
            InterstitialAdBridgeAndroid.interstitialAds.Add(key, interstitialAdContainer);
            InterstitialAdBridgeAndroid.lastKey++;
            return key;
        }