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); }
private static void adViewDidFinishClickBridgeCallback(int uniqueId) { AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId); if (container && container.onFinishedClick != null) { container.onFinishedClick(); } }
private static void adViewDidFailWithErrorBridgeCallback(int uniqueId, string error) { AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId); if (container && container.onError != null) { container.onError(error); } }
private static void adViewWillLogImpressionBridgeCallback(int uniqueId) { AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId); if (container && container.onImpression != null) { container.onImpression(); } }
private static void adViewDidLoadBridgeCallback(int uniqueId) { AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId); if (container && container.onLoad != null) { container.onLoad(); } }
public override void OnFinishedClick(int uniqueId, FBAdViewBridgeCallback callback) { AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId); if (container) { container.onFinishedClick = callback; } }
public override void OnError(int uniqueId, FBAdViewBridgeErrorCallback callback) { AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId); if (container) { container.onError = callback; } }
public override void OnImpression(int uniqueId, FBAdViewBridgeCallback callback) { AdViewContainer container = AdViewBridgeIOS.adViewContainerForAdViewId(uniqueId); if (container) { container.onImpression = callback; } }
// 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); } }
private AndroidJavaObject adViewForAdViewId(int uniqueId) { AdViewContainer value = null; if (adViews.TryGetValue(uniqueId, out value)) { return(value.bridgedAdView); } return(null); }
public override int Load(int uniqueId, String bidPayload) { AdUtility.Prepare(); AdViewContainer adViewContainer = AdViewContainerForAdViewId(uniqueId); if (adViewContainer != null) { adViewContainer.Load(bidPayload); } return(uniqueId); }
private static AdViewContainer adViewContainerForAdViewId(int uniqueId) { AdViewContainer adView = null; bool success = AdViewBridgeIOS.adViews.TryGetValue(uniqueId, out adView); if (success) { return(adView); } else { return(null); } }
private AndroidJavaObject adViewForAdViewId(int uniqueId) { AdViewContainer adViewContainer = null; bool success = AdViewBridgeAndroid.adViews.TryGetValue(uniqueId, out adViewContainer); if (success) { return(adViewContainer.bridgedAdView); } else { return(null); } }
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); }
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); }
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; }