使用するライブラリ
docs.expo.dev
導入手順
インストール
$ expo install expo-ads-admob
Front
import { Platform } from 'react-native';
import { AdMobBanner } from 'expo-ads-admob';
const bannerError = () => {
console.log("AdMob Fail error")
}
<View style={styles.admobBanner}>
<AdMobBanner
adUnitID={
__DEV__ ? "ca-app-pub-3940256099942544/2934735716" // テスト広告
: Platform.select({
ios: "ca-app-pub-3940256099942544/2934735716" , // iOS
android:"ca-app-pub-3940256099942544/2934735716" , // android
})
}
onDidFailToReceiveAdWithError={bannerError}
/>
</View>
style
admobBanner: {
width:'100%',
position:'absolute',
bottom: 0,
backgroundColor: '#fff',
}
テスト用ID
developers.google.com
参考サイト
honmushi.com