Reputation: 985
I tried using react-native-admob package for displaying ads and I followed the instructions in here: https://www.npmjs.com/package/react-native-admob
After setting it up, I'm getting an error:
Upvotes: 2
Views: 1200
Reputation: 2162
Step-1. Add below line at top in node-modules/react-native-admob/RNAdmobBanner.js and RNPublisherBanner.js
import PropTypes from "prop-types";
Step-2. Delete these line from both file(May be line no is 48 and 50 respective)
style: View.propTypes.style
note: style property of AdmobBanner is not working at all so you can delete this because this is creating issue.
Step-3. Change this words in both file
React.PropTypes ===> to ===> PropTypes
old Content=>
bannerSize: React.PropTypes.string,
adUnitID: React.PropTypes.string,
testDeviceID: React.PropTypes.string,
adViewDidReceiveAd: React.PropTypes.func,
didFailToReceiveAdWithError: React.PropTypes.func,
adViewWillPresentScreen: React.PropTypes.func,
adViewWillDismissScreen: React.PropTypes.func,
adViewDidDismissScreen: React.PropTypes.func,
adViewWillLeaveApplication: React.PropTypes.func,
admobDispatchAppEvent: React.PropTypes.func,
new content should be like this=>
bannerSize: PropTypes.string,
adUnitID: PropTypes.string,
testDeviceID: PropTypes.string,
adViewDidReceiveAd: PropTypes.func,
didFailToReceiveAdWithError: PropTypes.func,
adViewWillPresentScreen: PropTypes.func,
adViewWillDismissScreen: PropTypes.func,
adViewDidDismissScreen: PropTypes.func,
adViewWillLeaveApplication: PropTypes.func,
admobDispatchAppEvent: PropTypes.func,
Reference: https://github.com/facebook/react-native/issues/16542#issuecomment-415751870
OR
react-native unlink react-native-admob
npm uninstall react-native-admob
npm install -save react-native-admob@next
Docs: https://github.com/sbugert/react-native-admob
Reference: https://github.com/sbugert/react-native-admob/issues/391#issuecomment-451253909
For, react-native-admob@next
, use adSize
property instead of bannerSize
Upvotes: 1
Reputation: 30904
Install the beta version of this plugin. This problem sorts out in this version. the package.json will look like this.
"react-native-admob": "^2.0.0-beta.6",
Or run this command
npm i [email protected]
Upvotes: 0