在 React-native 中添加广告 admob
Add ads admob in React-native
我正在使用 expo 调试应用程序。在调试模式下 (expo start
) 广告正确显示
在我构建应用程序时(expo build: android
)不显示广告
使用测试密钥时,广告在 apk 中正常工作
检查了密钥。 google admob 已激活
我是否需要进行一些设置才能显示 admob 广告
我看了那里的文档,只描述了如何将代码插入到程序中。我使用库 expo-ads-admob
<View style = {{ width: '100%', alignItems: 'center' }}>
<AdMobBanner
bannerSize="fullBanner"
adUnitID="ca-app-pub-3940256099942544/6300978111"
testDeviceID="EMULATOR" />
<TouchableHighlight onPress={() =>{this.props.navigation.navigate('SearchObjectPage');} style={{
marginTop: 30,
width: '90%',
padding: 10,
backgroundColor: '#a1cfed',
}}>
<View>
<View style={{flexDirection:'row'}}>
<Image source={require('./src/red.png')} style={ styles.button } resizeMode="contain"/><Text style = { styles.text }>{'check'}</Text>
</View>
</View>
</TouchableHighlight>
</View>
对于simulators/emulators,您可以使用EMULATOR
作为测试设备ID。
但是,如果您创建一个 apk,该设备将不会运行,因为它不是模拟器。
我正在使用 expo 调试应用程序。在调试模式下 (expo start
) 广告正确显示
在我构建应用程序时(expo build: android
)不显示广告
使用测试密钥时,广告在 apk 中正常工作
检查了密钥。 google admob 已激活
我是否需要进行一些设置才能显示 admob 广告
我看了那里的文档,只描述了如何将代码插入到程序中。我使用库 expo-ads-admob
<View style = {{ width: '100%', alignItems: 'center' }}>
<AdMobBanner
bannerSize="fullBanner"
adUnitID="ca-app-pub-3940256099942544/6300978111"
testDeviceID="EMULATOR" />
<TouchableHighlight onPress={() =>{this.props.navigation.navigate('SearchObjectPage');} style={{
marginTop: 30,
width: '90%',
padding: 10,
backgroundColor: '#a1cfed',
}}>
<View>
<View style={{flexDirection:'row'}}>
<Image source={require('./src/red.png')} style={ styles.button } resizeMode="contain"/><Text style = { styles.text }>{'check'}</Text>
</View>
</View>
</TouchableHighlight>
</View>
对于simulators/emulators,您可以使用EMULATOR
作为测试设备ID。
但是,如果您创建一个 apk,该设备将不会运行,因为它不是模拟器。