From 54bf957cb369a8b23f4af1c8344e3397635d04ca Mon Sep 17 00:00:00 2001 From: Elliot Hesp Date: Tue, 20 Jun 2017 12:19:26 +0100 Subject: [PATCH] [admob] Support 11.0 VideoController methods --- .../firebase/admob/RNFirebaseAdMobBanner.java | 3 - .../admob/RNFirebaseAdMobNativeExpress.java | 26 ++++-- docs/modules/admob.md | 26 +++++- ios/RNFirebase/admob/NativeExpressComponent.m | 24 ++++- lib/modules/admob/AdMobComponent.js | 5 +- lib/modules/admob/Banner.js | 1 - lib/modules/admob/NativeExpress.js | 2 - lib/modules/admob/index.js | 4 + tests/src/main.admob.js | 87 +++++++++++++++++++ 9 files changed, 160 insertions(+), 18 deletions(-) create mode 100644 tests/src/main.admob.js diff --git a/android/src/main/java/io/invertase/firebase/admob/RNFirebaseAdMobBanner.java b/android/src/main/java/io/invertase/firebase/admob/RNFirebaseAdMobBanner.java index 555b2369..8aa2a643 100644 --- a/android/src/main/java/io/invertase/firebase/admob/RNFirebaseAdMobBanner.java +++ b/android/src/main/java/io/invertase/firebase/admob/RNFirebaseAdMobBanner.java @@ -208,9 +208,6 @@ public class RNFirebaseAdMobBanner extends SimpleViewManager { payload.putBoolean(RNFirebaseAdMobNativeExpress.Events.EVENT_AD_VIDEO_CONTENT.toString(), false); payload.putInt("width", width); payload.putInt("height", height); - payload.putInt("left", left); - payload.putInt("top", top); - sendEvent(Events.EVENT_AD_LOADED.toString(), payload); } diff --git a/android/src/main/java/io/invertase/firebase/admob/RNFirebaseAdMobNativeExpress.java b/android/src/main/java/io/invertase/firebase/admob/RNFirebaseAdMobNativeExpress.java index 0e466068..583efda2 100644 --- a/android/src/main/java/io/invertase/firebase/admob/RNFirebaseAdMobNativeExpress.java +++ b/android/src/main/java/io/invertase/firebase/admob/RNFirebaseAdMobNativeExpress.java @@ -34,6 +34,10 @@ public class RNFirebaseAdMobNativeExpress extends SimpleViewManager { @@ -60,6 +60,7 @@ class AdMobComponent extends React.Component { * @param nativeEvent */ onBannerEvent = ({ nativeEvent }) => { + console.log('EVENT', nativeEvent) if (this.props[nativeEvent.type]) { if (nativeEvent.type === 'onAdFailedToLoad') { const { code, message } = nativeEvent.payload; diff --git a/lib/modules/admob/Banner.js b/lib/modules/admob/Banner.js index d3b7a375..c3554703 100644 --- a/lib/modules/admob/Banner.js +++ b/lib/modules/admob/Banner.js @@ -13,7 +13,6 @@ function Banner({ ...props }) { Banner.propTypes = AdMobComponent.propTypes; Banner.defaultProps = { - unitId: 'ca-app-pub-3940256099942544/2177258514', size: 'SMART_BANNER', }; diff --git a/lib/modules/admob/NativeExpress.js b/lib/modules/admob/NativeExpress.js index 7c429444..6ee7ecfa 100644 --- a/lib/modules/admob/NativeExpress.js +++ b/lib/modules/admob/NativeExpress.js @@ -13,8 +13,6 @@ function NativeExpress({ ...props }) { NativeExpress.propTypes = AdMobComponent.propTypes; NativeExpress.defaultProps = { - // unitId: 'ca-app-pub-3940256099942544/2177258514', - unitId: 'ca-app-pub-3940256099942544/8897359316', size: 'SMART_BANNER', }; diff --git a/lib/modules/admob/index.js b/lib/modules/admob/index.js index 62085258..00c13957 100644 --- a/lib/modules/admob/index.js +++ b/lib/modules/admob/index.js @@ -88,5 +88,9 @@ export const statics = { }, NativeExpressEventTypes: { onVideoEnd: 'onVideoEnd', + onVideoMute: 'onVideoMute', + onVideoPause: 'onVideoPause', + onVideoPlay: 'onVideoPlay', + onVideoStart: 'onVideoStart', }, }; diff --git a/tests/src/main.admob.js b/tests/src/main.admob.js new file mode 100644 index 00000000..60decc8f --- /dev/null +++ b/tests/src/main.admob.js @@ -0,0 +1,87 @@ +import React, { Component } from 'react'; +import { View, Button, Platform } from 'react-native'; +import fb from './firebase'; + +global.Promise = require('bluebird'); + +const unitId = { + ...Platform.select({ + android: { + banner: 'ca-app-pub-3940256099942544/6300978111', + express: 'ca-app-pub-3940256099942544/2793859312', + interstitial: 'ca-app-pub-3940256099942544/1033173712', + rewarded: 'ca-app-pub-3940256099942544/5224354917', + }, + ios: { + banner: 'ca-app-pub-3940256099942544/6300978111', + express: 'ca-app-pub-3940256099942544/4270592515', + interstitial: 'ca-app-pub-3940256099942544/1033173712', + rewarded: 'ca-app-pub-3940256099942544/1712485313', + }, + }), +}; + +const firebase = fb.native; + +// Components +const Banner = firebase.admob.Banner; +const NativeExpress = firebase.admob.NativeExpress; + +// API +const interstitial = firebase.admob().interstitial(unitId.interstitial); +interstitial.loadAd(); + +const rewarded = firebase.admob().rewarded(unitId.rewarded); +rewarded.loadAd(); + + +function bootstrap() { + // Remove logging on production + if (!__DEV__) { + console.log = () => { + }; + console.warn = () => { + }; + console.error = () => { + }; + console.disableYellowBox = true; + } + + class Root extends Component { + + showInterstitial() { + interstitial.show(); + }; + + showRewarded() { + rewarded.show(); + } + + render() { + return ( + + + +