2 Star 0 Fork 0

mirrors_gorangajic/react-native-admob

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
RNAdMobBanner.js 2.66 KB
一键复制 编辑 原始数据 按行查看 历史
import React from 'react';
import {
NativeModules,
requireNativeComponent,
View,
NativeEventEmitter,
} from 'react-native';
const RNBanner = requireNativeComponent('RNAdMob', AdMobBanner);
export default class AdMobBanner extends React.Component {
constructor() {
super();
this.onSizeChange = this.onSizeChange.bind(this);
this.state = {
style: {},
};
}
onSizeChange(event) {
const { height, width } = event.nativeEvent;
this.setState({ style: { width, height } });
}
render() {
const { adUnitID, testDeviceID, bannerSize, style, didFailToReceiveAdWithError } = this.props;
return (
<View style={this.props.style}>
<RNBanner
style={this.state.style}
onSizeChange={this.onSizeChange.bind(this)}
onAdViewDidReceiveAd={this.props.adViewDidReceiveAd}
onDidFailToReceiveAdWithError={(event) => didFailToReceiveAdWithError(event.nativeEvent.error)}
onAdViewWillPresentScreen={this.props.adViewWillPresentScreen}
onAdViewWillDismissScreen={this.props.adViewWillDismissScreen}
onAdViewDidDismissScreen={this.props.adViewDidDismissScreen}
onAdViewWillLeaveApplication={this.props.adViewWillLeaveApplication}
testDeviceID={testDeviceID}
adUnitID={adUnitID}
bannerSize={bannerSize} />
</View>
);
}
}
AdMobBanner.propTypes = {
style: View.propTypes.style,
/**
* AdMob iOS library banner size constants
* (https://developers.google.com/admob/ios/banner)
* banner (320x50, Standard Banner for Phones and Tablets)
* largeBanner (320x100, Large Banner for Phones and Tablets)
* mediumRectangle (300x250, IAB Medium Rectangle for Phones and Tablets)
* fullBanner (468x60, IAB Full-Size Banner for Tablets)
* leaderboard (728x90, IAB Leaderboard for Tablets)
* smartBannerPortrait (Screen width x 32|50|90, Smart Banner for Phones and Tablets)
* smartBannerLandscape (Screen width x 32|50|90, Smart Banner for Phones and Tablets)
*
* banner is default
*/
bannerSize: React.PropTypes.string,
/**
* AdMob ad unit ID
*/
adUnitID: React.PropTypes.string,
/**
* Test device ID
*/
testDeviceID: React.PropTypes.string,
/**
* AdMob iOS library events
*/
adViewDidReceiveAd: React.PropTypes.func,
didFailToReceiveAdWithError: React.PropTypes.func,
adViewWillPresentScreen: React.PropTypes.func,
adViewWillDismissScreen: React.PropTypes.func,
adViewDidDismissScreen: React.PropTypes.func,
adViewWillLeaveApplication: React.PropTypes.func,
...View.propTypes,
};
AdMobBanner.defaultProps = { bannerSize: 'smartBannerPortrait', didFailToReceiveAdWithError: () => {} };
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_gorangajic/react-native-admob.git
git@gitee.com:mirrors_gorangajic/react-native-admob.git
mirrors_gorangajic
react-native-admob
react-native-admob
master

搜索帮助