[admob] Update documentation
This commit is contained in:
parent
5b39ab3efe
commit
fdcf4ef2f3
|
@ -8,13 +8,33 @@ RNFirebase allows you to display Banners, Interstitials, Native Ads & Rewarded V
|
|||
|
||||
AdMob Banners in RNFirebase are exported as a usable React component, allowing you to integrate it easily into your existing app very easily.
|
||||
|
||||
#### Props
|
||||
|
||||
| Prop | Type | Default | Description |
|
||||
| ------------------- | ------------------ | -------------------------------------- | ----------------------------------------------------------------------------------- |
|
||||
| size | string (See Sizes) | SMART_BANNER | Returns a sized banner (automatically sets View style) |
|
||||
| unitId | string | ca-app-pub-3940256099942544/6300978111 | Your AdMob banner unit ID. Default is the Google testing account |
|
||||
| testing | boolean | true | Whether the current device ID should be assigned as a test device |
|
||||
| onAdLoaded | function | | Called when an ad is received. |
|
||||
| onAdOpened | function | | Called when an ad opens an overlay that covers the screen. |
|
||||
| onAdLeftApplication | function | | Called when an ad leaves the application (e.g., to go to the browser). |
|
||||
| onAdClosed | function | | Called when the user is about to return to the application after clicking on an ad. |
|
||||
| onAdFailedToLoad | function | | Called when an ad request failed. See Error Handling |
|
||||
|
||||
?> See Event Types for more information.
|
||||
|
||||
#### Example
|
||||
|
||||
```js
|
||||
const Banner = firebase.admob.Banner;
|
||||
...
|
||||
render() {
|
||||
return (
|
||||
<Banner
|
||||
|
||||
size={"LARGE_BANNER"}
|
||||
onAdLoaded={() => {
|
||||
console.log('Advert loaded and is now visible');
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -29,6 +49,19 @@ method calls.
|
|||
|
||||
To request an interstitial from AdMob, the `loadAd` method must be called with an instance of `AdRequest` (see below for full API):
|
||||
|
||||
#### Methods
|
||||
|
||||
| Method | Description |
|
||||
| ------------------- | ---------------------------------------------------------------------------- |
|
||||
| loadAd(AdRequest) | Loads an advert with request config |
|
||||
| on(event, callback) | Listens to advert events. See Event Types |
|
||||
| isLoaded() | Returns a boolean value as to whether the advert is loaded and ready to show |
|
||||
| show() | Show the advert on the device |
|
||||
|
||||
?> See Event Types for more information.
|
||||
|
||||
#### Example
|
||||
|
||||
```js
|
||||
const advert = firebase.admob().interstitial('ca-app-pub-3940256099942544/1033173712');
|
||||
|
||||
|
@ -39,6 +72,10 @@ request.addKeyword('foo').addKeyword('bar');
|
|||
// Load the advert with our AdRequest
|
||||
advert.loadAd(request.build());
|
||||
|
||||
advert.on('onAdLoaded', () => {
|
||||
console.log('Advert ready to show.');
|
||||
});
|
||||
|
||||
// Simulate the interstitial being shown "sometime" later during the apps lifecycle
|
||||
setTimeout(() => {
|
||||
if (advert.isLoaded()) {
|
||||
|
@ -47,23 +84,90 @@ setTimeout(() => {
|
|||
// Unable to show interstitial - not loaded yet.
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
```
|
||||
|
||||
### Native
|
||||
|
||||
### Rewarded Video
|
||||
|
||||
## Statics
|
||||
A rewarded video allows you to display a video to a user, whereby they're able to watch it to gain "rewards", or skip it
|
||||
and receive nothing. For example, when a user completes a level on your gaming app, show them a video which will give them in-game
|
||||
credit.
|
||||
|
||||
### Banner
|
||||
> Accessed via `firebase.admob.Banner`.
|
||||
?> It's recommended you begin loading the video as soon as possible.
|
||||
|
||||
Exports a React component with the following PropTypes:
|
||||
To request an Rewarded Video from AdMob, the `loadAd` method must be called with an instance of `AdRequest` (see below for full API):
|
||||
|
||||
#### Methods
|
||||
|
||||
| Method | Description |
|
||||
| ------------------- | ---------------------------------------------------------------------------- |
|
||||
| loadAd(AdRequest) | Loads an advert with request config |
|
||||
| on(event, callback) | Listens to advert events. See Event Types |
|
||||
| isLoaded() | Returns a boolean value as to whether the advert is loaded and ready to show |
|
||||
| show() | Show the advert on the device |
|
||||
|
||||
?> See Event Types for more information.
|
||||
|
||||
#### Example
|
||||
|
||||
```js
|
||||
const advert = firebase.admob().rewarded('ca-app-pub-3940256099942544/1033173712');
|
||||
|
||||
const AdRequest = firebase.admob.AdRequest;
|
||||
const request = new AdRequest();
|
||||
request.addKeyword('foo').addKeyword('bar');
|
||||
|
||||
// Load the advert with our AdRequest
|
||||
advert.loadAd(request.build());
|
||||
|
||||
advert.on('onAdLoaded', () => {
|
||||
console.log('Advert ready to show.');
|
||||
});
|
||||
|
||||
advert.on('onRewarded', (event) => {
|
||||
console.log('The user watched the entire video and will now be rewarded!', event);
|
||||
});
|
||||
|
||||
...
|
||||
|
||||
onLevelComplete()
|
||||
.then(() => {
|
||||
if (advert.isLoaded()) {
|
||||
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### AdRequest
|
||||
> Accessed via `firebase.admob.AdRequest`.
|
||||
|
||||
Used to build a request object to pass into AdMob requests. Exposes the following chainable methods:
|
||||
##### addTestDevice()
|
||||
Sets the current device as a test device.
|
||||
|
||||
##### addKeyword(keyword: string)
|
||||
Add a new keyword to relate the advert to.
|
||||
|
||||
##### setBirthday(date: Date)
|
||||
|
||||
##### setGender()
|
||||
|
||||
##### setLocation()
|
||||
|
||||
##### setRequestAgent()
|
||||
|
||||
##### setIsDesignedForFamilies(forFamilies: boolean)
|
||||
|
||||
##### tagForChildDirectedTreatment(forChildren: boolean)
|
||||
|
||||
## Statics
|
||||
|
||||
The following statics are available on the `firebase.admob` instance.
|
||||
|
||||
### Banner
|
||||
|
||||
Exports a React component to display an AdMob Banner.
|
||||
|
||||
### AdRequest
|
||||
|
||||
Used to build a request object to pass into AdMob requests.
|
||||
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
@implementation RNFirebaseAdMob
|
||||
RCT_EXPORT_MODULE();
|
||||
|
||||
RCT_EXPORT_METHOD(log:(NSString *)message) {
|
||||
FIRCrashLog(message);
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(nativeSDKMissing) {}
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in New Issue