[admob] Add openDebugMenu support
This commit is contained in:
parent
9c293ef1e5
commit
c22fb3911f
|
@ -45,6 +45,11 @@ public class RNFirebaseAdMob extends ReactContextBaseJavaModule {
|
|||
MobileAds.initialize(this.getContext(), appId);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void openDebugMenu(String appId) {
|
||||
MobileAds.openDebugMenu(getActivity(), appId);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void interstitialLoadAd(String adUnit, ReadableMap request) {
|
||||
RNFirebaseAdmobInterstitial interstitial = getOrCreateInterstitial(adUnit);
|
||||
|
|
|
@ -13,6 +13,15 @@ Initialize takes your AdMob App ID, where you can find on your AdMob dashboard.
|
|||
firebase.admob().initialize("ca-app-pub-3940256099942544~3347511713");
|
||||
```
|
||||
|
||||
## Debugging
|
||||
|
||||
Once initialized, you can debug ((Android)[https://developers.google.com/mobile-ads-sdk/docs/dfp/android/debug]/(iOS)[https://developers.google.com/mobile-ads-sdk/docs/dfp/ios/debug])
|
||||
your ads using the debug menu.
|
||||
|
||||
```js
|
||||
firebase.admob().openDebugMenu();
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### Banner
|
||||
|
|
|
@ -32,6 +32,14 @@ RCT_EXPORT_METHOD(initialize:
|
|||
[GADMobileAds configureWithApplicationID:appId];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(openDebugMenu:
|
||||
(NSString *) appId) {
|
||||
GADDebugOptionsViewController *debugOptionsViewController = [GADDebugOptionsViewController debugOptionsViewControllerWithAdUnitID:appId];
|
||||
UIWindow* window = [UIApplication sharedApplication].keyWindow;
|
||||
|
||||
[[window rootViewController] presentViewController:debugOptionsViewController animated:YES completion:nil];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(interstitialLoadAd:
|
||||
(NSString *) adUnit
|
||||
request:
|
||||
|
|
|
@ -21,6 +21,7 @@ export default class Admob extends Base {
|
|||
}
|
||||
|
||||
this._initialized = false;
|
||||
this._appId = null;
|
||||
FirebaseAdMobEvt.addListener('interstitial_event', this._onInterstitialEvent.bind(this));
|
||||
FirebaseAdMobEvt.addListener('rewarded_video_event', this._onRewardedVideoEvent.bind(this));
|
||||
}
|
||||
|
@ -54,9 +55,20 @@ export default class Admob extends Base {
|
|||
}
|
||||
|
||||
this._initialized = true;
|
||||
this._appId = appId;
|
||||
return FirebaseAdMob.initialize(appId);
|
||||
}
|
||||
|
||||
openDebugMenu() {
|
||||
if (!this._initialized) {
|
||||
this.log.warn('AdMob needs to be initialized before opening the dev menu!');
|
||||
return;
|
||||
}
|
||||
|
||||
this.log.info('Opening debug menu');
|
||||
return FirebaseAdMob.openDebugMenu(this._appId);
|
||||
}
|
||||
|
||||
interstitial(adUnit: string) {
|
||||
return new Interstitial(this, adUnit);
|
||||
}
|
||||
|
@ -68,6 +80,10 @@ export default class Admob extends Base {
|
|||
static get statics() {
|
||||
return statics;
|
||||
}
|
||||
|
||||
get namespace(): string {
|
||||
return 'firebase:admob';
|
||||
}
|
||||
}
|
||||
|
||||
export const statics = {
|
||||
|
|
|
@ -22,6 +22,7 @@ export default function addTests({ before, fdescribe, describe, it, firebase })
|
|||
const admob = firebase.native.admob();
|
||||
|
||||
admob.should.have.property('initialize').and.be.a.Function();
|
||||
admob.should.have.property('openDebugMenu').and.be.a.Function();
|
||||
admob.should.have.property('interstitial').and.be.a.Function();
|
||||
admob.should.have.property('rewarded').and.be.a.Function();
|
||||
resolve();
|
||||
|
|
Loading…
Reference in New Issue