简体   繁体   English

在React-native中添加广告admob

[英]Add ads admob in React-native

I am using expo to debug an application. 我正在使用expo调试应用程序。 In debug mode ( expo start ) advertising is correctly displayed 在调试模式( expo start )中,广告正确显示

on when I build the application ( expo build: android ) advertising is not displayed 在我构建应用程序( expo build: android )时未显示广告

when using the test key, the advertisement works correctly in apk 使用测试键时,广告在apk中可以正常工作

checked the key. 检查了钥匙。 google admob it's active google admob,它处于活动状态

Do I need to make some settings to display admob ads 我是否需要进行一些设置才能显示admob广告

I watched the documentation there described only about inserting the code into the program. 我看到那里的文档仅描述了将代码插入程序中。 I use the library expo-ads-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>

For simulators/emulators you can use EMULATOR for the test device ID. 对于模拟器/仿真器 ,可以将EMULATOR用作测试设备ID。

However, if you create an apk, the divice will not run because it is not an emulator. 但是,如果创建apk,则该设备不会运行,因为它不是模拟器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM