Expo Docs

Hey friend! We are co-hosting a conference with Software Mansion, learn more.

Admob

Expo includes support for the Google AdMob SDK for mobile advertising. This module is largely based of the react-native-admob module, as the documentation and questions surrounding that module may prove helpful. A simple example implementing AdMob SDK can be found here.

import {
  AdMobBanner,
  AdMobInterstitial,
  PublisherBanner,
  AdMobRewarded
} from 'expo';

// Display a banner
<AdMobBanner
  bannerSize="fullBanner"
  adUnitID="ca-app-pub-3940256099942544/6300978111" // Test ID, Replace with your-admob-unit-id
  testDeviceID="EMULATOR"
  onDidFailToReceiveAdWithError={this.bannerError} />

// Display a DFP Publisher banner
<PublisherBanner
  bannerSize="fullBanner"
  adUnitID="ca-app-pub-3940256099942544/6300978111" // Test ID, Replace with your-admob-unit-id
  testDeviceID="EMULATOR"
  onDidFailToReceiveAdWithError={this.bannerError}
  onAdMobDispatchAppEvent={this.adMobEvent} />

// Display an interstitial
AdMobInterstitial.setAdUnitID('ca-app-pub-3940256099942544/1033173712'); // Test ID, Replace with your-admob-unit-id
AdMobInterstitial.setTestDeviceID('EMULATOR');
await AdMobInterstitial.requestAdAsync();
await AdMobInterstitial.showAdAsync();

// Display a rewarded ad
AdMobRewarded.setAdUnitID('ca-app-pub-3940256099942544/1033173712'); // Test ID, Replace with your-admob-unit-id
AdMobRewarded.setTestDeviceID('EMULATOR');
await AdMobRewarded.requestAdAsync();
await AdMobRewarded.showAdAsync();

Prop valueDescriptionSize
bannerStandard Banner for Phones and Tablets320x50
largeBannerLarge Banner for Phones and Tablets320x100
mediumRectangleIAB Medium Rectangle for Phones and Tablets300x250
fullBannerIAB Full-Size Banner for Tablet468x60
leaderboardIAB Leaderboard for Tablets728x90
smartBannerPortraitSmart Banner for Phones and Tablets (default)Screen width x 32
smartBannerLandscapeSmart Banner for Phones and TabletsScreen width x 32
Note: There is no smartBannerPortrait and smartBannerLandscape on Android. Both prop values will map to smartBanner

Prop
onAdViewDidReceiveAd()
onDidFailToReceiveAdWithError(errorDescription: string)
onAdViewWillPresentScreen()
onAdViewWillDismissScreen()
onAdViewDidDismissScreen()
onAdViewWillLeaveApplication()

NameDescription
setAdUnitID(adUnitID)sets the AdUnit ID for all future ad requests.
setTestDeviceID(deviceID)sets the test device ID
requestAdAsync()requests an interstitial and resolves when interstitialDidLoad or interstitialDidFailToLoad event fires
showAdAsync()shows an interstitial if it is ready and resolves when interstitialDidOpen event fires
getIsReadyAsync()resolves with boolean whether interstitial is ready to be shown
For simulators/emulators you can use 'EMULATOR' for the test device ID.

Unfortunately, events are not consistent across iOS and Android. To have one unified API, new event names are introduced for pairs that are roughly equivalent.
iOSthis libraryAndroid
interstitialDidReceiveAdinterstitialDidLoadonAdLoaded
interstitial:didFailToReceiveAdWithErrorinterstitialDidFailToLoadonAdFailedToLoad
interstitialWillPresentScreeninterstitialDidOpenonAdOpened
interstitialDidFailToPresentScreen
interstitialWillDismissScreen
interstitialDidDismissScreeninterstitialDidCloseonAdClosed
interstitialWillLeaveApplicationinterstitialWillLeaveApplicationonAdLeftApplication
Note that interstitialWillLeaveApplication and onAdLeftApplication are not exactly the same but share one event in this library.

Opens a rewarded AdMob ad.

NameDescription
setAdUnitID(adUnitID: string)sets the AdUnit ID for all future ad requests.
setTestDeviceID(testDeviceID: string)sets the test device ID
requestAdAsync()(async) requests a rewarded ad
showAdAsync()(async) shows a rewarded if it is ready (async)

iOSthis libraryAndroid
rewardBasedVideoAd:didRewardUserWithRewardrewardedVideoDidRewardUseronRewarded
rewardBasedVideoAdDidReceiveAdrewardedVideoDidLoadonRewardedVideoAdLoaded
rewardBasedVideoAd:didFailToLoadWithErrorrewardedVideoDidFailToLoadonRewardedVideoAdFailedToLoad
rewardBasedVideoAdDidOpenrewardedVideoDidOpenonRewardedVideoAdOpened
rewardedVideoDidCompleteonRewardedVideoCompleted
rewardBasedVideoAdDidCloserewardedVideoDidCloseonRewardedVideoAdClosed
rewardBasedVideoAdWillLeaveApplicationrewardedVideoWillLeaveApplicationonRewardedVideoAdLeftApplication