react-native-admob在我的RN <57.8应用程序中不起作用
我尝试过:
npm install react-native-admob@next --save
npm install @types/react-native-admob
npm i react-native-admob -S
npm install
react-native link
声明模块'react-native-admob'
将工具更新为28.0.3
import { AdMobBanner } from 'react-native-admob';
export default class Intro extends React.Component {
bannerError(err){
console.log(err)
}
render() {
return (
<Container style={styles.container}>
<ImageBackground style={{width:'100%',height:'100%',}} source= {require('../assets/start1.jpg')}>
<AdMobBanner
bannerSize="fullBanner"
adUnitID="ca-app-pub-3940256099942544/2934735716"
testDeviceID="EMULATOR"
didFailToReceiveAdWithError={this.bannerError} />
</ImageBackground >
</Container>
);
}
}
错误
找不到模块'react-native-admob'的声明文件。 'e:/react/almustaqbal/node_modules/react-native-admob/index.js' 隐式地具有“ any”类型。尝试
npm install @types/react-native-admob
(如果存在)或添加新的声明 (.d.ts)文件包含declare module 'react-native-admob';
ts(7016)
答案 0 :(得分:0)
尝试了很多次后,我猜 react-native-admob 在 RN <57.8
中不起作用所以我发现在RN <57.8中工作的另一种方式是:
react-native-firebase
我发现此网站有很好的解释https://dev-yakuza.github.io/en/react-native/react-native-firebase-admob/