这是我上次尝试在React-Native中使用AdMob,它不起作用,但是前段时间使用相同的代码可以正常工作
控制台
react-native init testAdmob
cd testAdmob
npm i react-native-admob -S
react-native run-android
代码
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';
import {AdMobBanner} from 'react-native-admob'
type Props = {};
export default class App extends Component<Props> {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>Test AdMob</Text>
<AdMobBanner
adSize="fullBanner"
adUnitID="ca-app-pub-9341782679724067~4969206215"
testDevices={[AdMobBanner.simulatorId]}
onAdFailedToLoad={error => console.error(error)}
/>
</View>
);
}
}
...
包装
...
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-admob": "^1.3.2"
}
...
错误
感谢您的帮助