diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 000000000..691fadb37 --- /dev/null +++ b/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; + +export const AdMobInterstitial: { + setAdUnitID: (adUnitID: string) => void; + setTestDevices: (testDevices: string[]) => void; + requestAd: () => Promise; + showAd: () => Promise; + 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; + +export const AdMobRewarded: { + setAdUnitID: (adUnitID: string) => void; + setTestDevices: (testDevices: string[]) => void; + requestAd: () => Promise; + showAd: () => Promise; + 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'; +}; diff --git a/package.json b/package.json index 358fb0cc4..6ee02be48 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "A react-native component for Google AdMob banners and interstitials", "author": "Simon Bugert ", "main": "index.js", + "types": "index.d.ts", "license": "BSD-2-Clause", "repository": { "type": "git",