Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Typescript definition #578

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
143 changes: 143 additions & 0 deletions index.d.ts
@@ -0,0 +1,143 @@
import { ViewProps } from 'react-native';

interface AdMobBannerProps extends ViewProps {
/**
* AdMob iOS library banner size constants
* (https://developers.google.com/admob/ios/banner)
* banner (320x50, Standard Banner for Phones and Tablets)
* largeBanner (320x100, Large Banner for Phones and Tablets)
* mediumRectangle (300x250, IAB Medium Rectangle for Phones and Tablets)
* fullBanner (468x60, IAB Full-Size Banner for Tablets)
* leaderboard (728x90, IAB Leaderboard for Tablets)
* smartBannerPortrait (Screen width x 32|50|90, Smart Banner for Phones and Tablets)
* smartBannerLandscape (Screen width x 32|50|90, Smart Banner for Phones and Tablets)
*
* banner is default
*/
adSize?:
| 'banner'
| 'largeBanner'
| 'mediumRectangle'
| 'fullBanner'
| 'leaderboard'
| 'smartBannerPortrait'
| 'smartBannerLandscape';

/**
* AdMob ad unit ID
*/
adUnitID: string;

/**
* Array of test devices. Use AdMobBanner.simulatorId for the simulator
*/
testDevices?: string[];

/**
* AdMob iOS library events
*/
onSizeChange?: Function;

onAdLoaded?: Function;
onAdFailedToLoad?: (err: Error) => any;
onAdOpened?: Function;
onAdClosed?: Function;
onAdLeftApplication?: Function;
}
export const AdMobBanner: React.FC<AdMobBannerProps>;

export const AdMobInterstitial: {
setAdUnitID: (adUnitID: string) => void;
setTestDevices: (testDevices: string[]) => void;
requestAd: () => Promise<unknown>;
showAd: () => Promise<unknown>;
isReady: (callback: Function) => void;
addEventListener: (
event:
| 'adLoaded'
| 'adFailedToLoad'
| 'adOpened'
| 'adClosed'
| 'adLeftApplication',
handler: Function
) => void;
removeEventListener: (type: unknown, handler: Function) => void;
removeAllListeners: () => void;
simulatorId: 'SIMULATOR';
};

interface PublisherBannerProps extends ViewProps {
/**
* DFP iOS library banner size constants
* (https://developers.google.com/admob/ios/banner)
* banner (320x50, Standard Banner for Phones and Tablets)
* largeBanner (320x100, Large Banner for Phones and Tablets)
* mediumRectangle (300x250, IAB Medium Rectangle for Phones and Tablets)
* fullBanner (468x60, IAB Full-Size Banner for Tablets)
* leaderboard (728x90, IAB Leaderboard for Tablets)
* smartBannerPortrait (Screen width x 32|50|90, Smart Banner for Phones and Tablets)
* smartBannerLandscape (Screen width x 32|50|90, Smart Banner for Phones and Tablets)
*
* banner is default
*/
adSize?:
| 'banner'
| 'largeBanner'
| 'mediumRectangle'
| 'fullBanner'
| 'leaderboard'
| 'smartBannerPortrait'
| 'smartBannerLandscape';

/**
* Optional array specifying all valid sizes that are appropriate for this slot.
*/
validAdSizes?: string[];

/**
* DFP ad unit ID
*/
adUnitID: string;

/**
* Array of test devices. Use PublisherBanner.simulatorId for the simulator
*/
testDevices?: string[];

onSizeChange?: Function;

/**
* DFP library events
*/
onAdLoaded?: Function;
onAdFailedToLoad?: (err: Error) => any;
onAdOpened?: Function;
onAdClosed?: Function;
onAdLeftApplication?: Function;
onAppEvent?: Function;
}

export const PublisherBanner: React.FC<PublisherBannerProps>;

export const AdMobRewarded: {
setAdUnitID: (adUnitID: string) => void;
setTestDevices: (testDevices: string[]) => void;
requestAd: () => Promise<unknown>;
showAd: () => Promise<unknown>;
isReady: (callback: Function) => void;
addEventListener: (
event:
| 'adLoaded'
| 'adFailedToLoad'
| 'adOpened'
| 'adClosed'
| 'adLeftApplication'
| 'rewarded'
| 'videoStarted'
| 'videoCompleted',
handler: Function
) => void;
removeEventListener: (type: unknown, handler: Function) => void;
removeAllListeners: () => void;
simulatorId: 'SIMULATOR';
};
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -4,6 +4,7 @@
"description": "A react-native component for Google AdMob banners and interstitials",
"author": "Simon Bugert <simon.bugert@gmail.com>",
"main": "index.js",
"types": "index.d.ts",
"license": "BSD-2-Clause",
"repository": {
"type": "git",
Expand Down