{"id":4792,"url":"https://github.com/sbugert/react-native-admob","last_synced_at":"2025-04-13T22:30:25.949Z","repository":{"id":3054694,"uuid":"47620152","full_name":"sbugert/react-native-admob","owner":"sbugert","description":"A react-native component for Google AdMob banners","archived":false,"fork":false,"pushed_at":"2023-01-03T16:56:10.000Z","size":1273,"stargazers_count":1130,"open_issues_count":224,"forks_count":532,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-04-14T05:59:54.542Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sbugert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-08T12:16:42.000Z","updated_at":"2024-03-31T14:17:04.000Z","dependencies_parsed_at":"2023-01-13T13:00:22.529Z","dependency_job_id":null,"html_url":"https://github.com/sbugert/react-native-admob","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbugert%2Freact-native-admob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbugert%2Freact-native-admob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbugert%2Freact-native-admob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbugert%2Freact-native-admob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbugert","download_url":"https://codeload.github.com/sbugert/react-native-admob/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248790520,"owners_count":21162026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:17:24.311Z","updated_at":"2025-04-13T22:30:25.903Z","avatar_url":"https://github.com/sbugert.png","language":"Java","readme":"# react-native-admob [![npm](https://img.shields.io/npm/v/react-native-admob.svg)](https://www.npmjs.com/package/react-native-admob) [![npm (next)](https://img.shields.io/npm/v/react-native-admob/next.svg)](https://www.npmjs.com/package/react-native-admob)\n\n### ⚠️ Please note, the master branch tracks development of version 2 of this library, which is currently in beta. For version 1 please check out the [1.x branch](https://github.com/sbugert/react-native-admob/tree/1.x).\n\nA react-native module for Google AdMob Banners, Interstitials, Rewarded Videos and also DFP Banners.\n\nThe banner types are implemented as components while the interstitial and rewarded video have an imperative API.\n\n## Installation\n\nYou can use npm or Yarn to install the latest beta version:\n\n**npm:**\n\n    npm i --save react-native-admob@next\n\n**Yarn:**\n\n    yarn add react-native-admob@next\n\nIn order to use this library, you have to link it to your project first. There's excellent documentation on how to do this in the [React Native Docs](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#content).\n\nAlternatively for iOS you can install the library with CocoaPods by adding a line to your `Podfile`;\n\n    pod 'react-native-admob', path: '../node_modules/react-native-admob'\n\n### iOS\n\nFor iOS you will have to add the [Google Mobile Ads SDK](https://developers.google.com/admob/ios/quick-start#import_the_mobile_ads_sdk) to your Xcode project.\n\n### Android\n\nOn Android the AdMob library code is part of Play Services, which is automatically added when this library is linked.\n\nBut you still have to manually update your `AndroidManifest.xml`, as described in the [Google Mobile Ads SDK documentation](https://developers.google.com/admob/android/quick-start#update_your_androidmanifestxml).\n\n## Usage\n\n```jsx\nimport {\n  AdMobBanner,\n  AdMobInterstitial,\n  PublisherBanner,\n  AdMobRewarded,\n} from 'react-native-admob'\n\n// Display a banner\n\u003cAdMobBanner\n  adSize=\"fullBanner\"\n  adUnitID=\"your-admob-unit-id\"\n  testDevices={[AdMobBanner.simulatorId]}\n  onAdFailedToLoad={error =\u003e console.error(error)}\n/\u003e\n\n// Display a DFP Publisher banner\n\u003cPublisherBanner\n  adSize=\"fullBanner\"\n  adUnitID=\"your-admob-unit-id\"\n  testDevices={[PublisherBanner.simulatorId]}\n  onAdFailedToLoad={error =\u003e console.error(error)}\n  onAppEvent={event =\u003e console.log(event.name, event.info)}\n/\u003e\n\n// Display an interstitial\nAdMobInterstitial.setAdUnitID('your-admob-unit-id');\nAdMobInterstitial.setTestDevices([AdMobInterstitial.simulatorId]);\nAdMobInterstitial.requestAd().then(() =\u003e AdMobInterstitial.showAd());\n\n// Display a rewarded ad\nAdMobRewarded.setAdUnitID('your-admob-unit-id');\nAdMobRewarded.requestAd().then(() =\u003e AdMobRewarded.showAd());\n```\n\nFor a full example reference to the [example project](Example).\n\n## Reference\n\n### AdMobBanner\n\n#### Properties\n\n##### `adSize`\n\n_Corresponding to [iOS framework banner size constants](https://developers.google.com/admob/ios/banner)_\n\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003eValue\u003c/th\u003e\n      \u003cth\u003eDescription\u003c/th\u003e\n      \u003cth\u003eAvailability\u003c/th\u003e\n      \u003cth\u003eSize (WxH)\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003ebanner\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eStandard Banner\u003c/td\u003e\n      \u003ctd\u003ePhones and Tablets\u003c/td\u003e\n      \u003ctd\u003e320x50\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003elargeBanner\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eLarge Banner\u003c/td\u003e\n      \u003ctd\u003ePhones and Tablets\u003c/td\u003e\n      \u003ctd\u003e320x100\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003emediumRectangle\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eIAB Medium Rectangle\u003c/td\u003e\n      \u003ctd\u003ePhones and Tablets\u003c/td\u003e\n      \u003ctd\u003e300x250\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003efullBanner\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eIAB Full-Size Banner\u003c/td\u003e\n      \u003ctd\u003eTablets\u003c/td\u003e\n      \u003ctd\u003e468x60\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eleaderboard\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eIAB Leaderboard\u003c/td\u003e\n      \u003ctd\u003eTablets\u003c/td\u003e\n      \u003ctd\u003e728x90\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\n        \u003ccode\u003esmartBannerPortrait\u003c/code\u003e\u003cbr/\u003e\n        \u003ccode\u003esmartBannerLandscape\u003c/code\u003e\n      \u003c/td\u003e\n      \u003ctd\u003eSmart Banner\u003c/td\u003e\n      \u003ctd\u003ePhones and Tablets\u003c/td\u003e\n      \u003ctd\u003eScreen width x 32|50|90\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n_Note: There is no `smartBannerPortrait` and `smartBannerLandscape` on Android. Both prop values will map to `smartBanner`_\n\n##### `onAdLoaded`\n\nAccepts a function. Called when an ad is received.\n\n##### `onAdFailedToLoad`\n\nAccepts a function. Called when an ad request failed.\n\n##### `onAdOpened`\n\nAccepts a function. Called when an ad opens an overlay that covers the screen.\n\n##### `onAdClosed`\n\nAccepts a function. Called when the user is about to return to the application after clicking on an ad.\n\n##### `onAdLeftApplication`\n\nAccepts a function. Called when a user click will open another app (such as the App Store), backgrounding the current app.\n\n##### `onSizeChange`\n\nAccepts a function. Called when the size of the banner changes. The function is called with an object containing the width and the height.\n\n_Above names correspond to the [Ad lifecycle event callbacks](https://developers.google.com/admob/android/banner#ad_events)_\n\n### PublisherBanner\n\n#### Properties\n\nSame as `AdMobBanner`, with the addition of 2 extra properties:\n\n##### `onAppEvent`\n\nAccepts a function. Called when DFP sends an event back to the app.\n\nThese events may occur at any time during the ad's lifecycle, even before `onAdLoaded` is called. The function is called with an object, containing the name of the event and an info property, containing additional information.\n\nMore info here: https://developers.google.com/mobile-ads-sdk/docs/dfp/ios/banner#app_events\n\n##### `validAdSizes`\n\nAn array of ad sizes which may be eligible to be served.\n\n### AdMobInterstitial\n\nIn comparison to the `AdMobBanner` and `PublisherBanner` which have a declaritive API, the `AdMobInterstitial` has an imperative API.\n\n#### Methods\n\n##### `setAdUnitID(adUnitID)`\n\nSets the AdUnit ID for all future ad requests.\n\n##### `setTestDevices(devices)`\n\nSets the devices which are served test ads.\n\n_For simulators/emulators you can use `AdMobInterstitial.simulatorId` for the test device ID._\n\n##### `requestAd()`\n\nRequests an interstitial and returns a promise, which resolves on load and rejects on error.\n\n##### `showAd()`\n\nShows an interstitial and returns a promise, which resolves when an ad is going to be shown, rejects when the ad is not ready to be shown.\n\n##### `isReady(callback)`\n\nCalls callback with a boolean value whether the interstitial is ready to be shown.\n\n#### Events\n\nUnfortunately, events are not consistent across iOS and Android. To have one unified API, new event names are introduced for pairs that are roughly equivalent.\n\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003eThis library\u003c/th\u003e\n      \u003cth\u003eiOS\u003c/th\u003e\n      \u003cth\u003eAndroid\u003c/th\u003e\n    \u003c/t\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eadLoaded\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003einterstitialDidReceiveAd\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eonAdLoaded\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eadFailedToLoad\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003einterstitial:didFailToReceiveAdWithError\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eonAdFailedToLoad\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eadOpened\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003einterstitialWillPresentScreen\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eonAdOpened\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eadFailedToOpen\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003einterstitialDidFailToPresentScreen\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003cem\u003eNot supported\u003c/em\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eadClosed\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003einterstitialWillDismissScreen\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eonAdClosed\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eadLeftApplication\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003einterstitialWillLeaveApplication\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eonAdLeftApplication\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n### AdMobRewarded\n\nIn comparison to the `AdMobBanner` and `PublisherBanner` which have a declaritive API, the `AdMobRewarded` has an imperative API, just like the `AdMobInterstitial`.\n\n#### Methods\n\n##### `setAdUnitID(adUnitID)`\n\nSets the AdUnit ID for all future ad requests.\n\n##### `setTestDevices(devices)`\n\nSets the devices which are served test ads.\n\n_For simulators/emulators you can use `AdMobRewarded.simulatorId` for the test device ID._\n\n##### `requestAd()`\n\nRequests a rewarded ad and returns a promise, which resolves on load and rejects on error.\n\n##### `showAd()`\n\nShows a rewarded ad and returns a promise, which resolves when an ad is going to be shown, rejects when the ad is not ready to be shown.\n\n##### `isReady(callback)`\n\nCalls callback with a boolean value whether the rewarded ad is ready to be shown.\n\n#### Events\n\nUnfortunately, events are not consistent across iOS and Android. To have one unified API, new event names are introduced for pairs that are roughly equivalent.\n\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003eThis library\u003c/th\u003e\n      \u003cth\u003eiOS\u003c/th\u003e\n      \u003cth\u003eAndroid\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eadLoaded\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003erewardBasedVideoAdDidReceiveAd\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eonRewardedVideoAdLoaded\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eadFailedToLoad\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003erewardBasedVideoAd:didFailToLoadWithError\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eonRewardedVideoAdFailedToLoad\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003erewarded\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003erewardBasedVideoAd:didRewardUserWithReward\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eonRewarded\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eadOpened\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003erewardBasedVideoAdDidOpen\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eonRewardedVideoAdOpened\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003evideoStarted\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003erewardBasedVideoAdDidStartPlaying\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eonRewardedVideoStarted\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003evideoCompleted\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003erewardBasedVideoAdDidCompletePlaying\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003erewardedVideoAdVideoCompleted\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eadClosed\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003erewardBasedVideoAdDidClose\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eonRewardedVideoAdClosed\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eadLeftApplication\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003erewardBasedVideoAdWillLeaveApplication\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eonRewardedVideoAdLeftApplication\u003c/code\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n---\n\n## TODO\n\n- [ ] Support [Ad Targeting](https://developers.google.com/admob/ios/targeting) (RFC: [#166](https://github.com/sbugert/react-native-admob/pull/166))\n","funding_links":[],"categories":["Components","Java","\u003ca name=\"Monetization:-Native-Modules\"\u003eMonetization: Native Modules\u003c/a\u003e"],"sub_categories":["Monetization"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbugert%2Freact-native-admob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbugert%2Freact-native-admob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbugert%2Freact-native-admob/lists"}