mirror of
https://github.com/expo/react-native-admob.git
synced 2026-11-15 17:39:02 -10:00
* Add basic rewarded video support for iOS * Add missing file RNAdMobRewarded.js * Got rewarded ads working on Android (#42) * Added non-working native module for rewarded ads. * Update android example to test rewarded ads. * Get rewarded videos working on android. * Add reward item detail to onReward listener. * Rewarded ads support (#80) * Fix simualtor mode on iOS (string comparison) * Fix the wrong testDeviceID controller in Android interstatial ads module. (#41) * Bump version * Added PublisherBanner ( DFPBanner [iOS] - PublisherAdView [Android]) (#52) * added initial PublisherAdBanner classes and configs for Android * updated ios module to have DFPBanner View implementation * updated readme * added PublisherBanner info to readme * Listen to onLayout changes to resize banner accordingly (#56) * Fix iOS framework link * Support for rewarded ads. Tested with both iOS and Android. Corrected event name. * Update RNAdMobRewarded.h Added support for RN 0.40
79 lines
2.1 KiB
JavaScript
79 lines
2.1 KiB
JavaScript
import React, { Component } from 'react';
|
|
import {
|
|
AppRegistry,
|
|
StyleSheet,
|
|
Text,
|
|
View,
|
|
Platform,
|
|
TouchableHighlight,
|
|
} from 'react-native';
|
|
import { AdMobRewarded } from 'react-native-admob';
|
|
|
|
export default class Example extends Component {
|
|
|
|
componentDidMount() {
|
|
AdMobRewarded.setTestDeviceID('EMULATOR');
|
|
AdMobRewarded.setAdUnitID('ca-app-pub-3940256099942544/1033173712');
|
|
|
|
AdMobRewarded.addEventListener('rewardedVideoDidRewardUser',
|
|
(type, amount) => console.log('rewardedVideoDidRewardUser', type, amount)
|
|
);
|
|
AdMobRewarded.addEventListener('rewardedVideoDidLoad',
|
|
() => console.log('rewardedVideoDidLoad')
|
|
);
|
|
AdMobRewarded.addEventListener('rewardedVideoDidFailToLoad',
|
|
(error) => console.log('rewardedVideoDidFailToLoad', error)
|
|
);
|
|
AdMobRewarded.addEventListener('rewardedVideoDidOpen',
|
|
() => console.log('rewardedVideoDidOpen')
|
|
);
|
|
AdMobRewarded.addEventListener('rewardedVideoDidClose',
|
|
() => {
|
|
console.log('rewardedVideoDidClose');
|
|
AdMobRewarded.requestAd((error) => error && console.log(error));
|
|
}
|
|
);
|
|
AdMobRewarded.addEventListener('rewardedVideoWillLeaveApplication',
|
|
() => console.log('rewardedVideoWillLeaveApplication')
|
|
);
|
|
|
|
AdMobRewarded.requestAd((error) => error && console.log(error));
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
AdMobRewarded.removeAllListeners();
|
|
}
|
|
|
|
showRewarded() {
|
|
AdMobRewarded.showAd((error) => error && console.log(error));
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<View style={styles.container}>
|
|
<View style={{ flex: 1 }}>
|
|
<TouchableHighlight>
|
|
<Text onPress={this.showRewarded} style={styles.button}>
|
|
Show Rewarded Video and preload next
|
|
</Text>
|
|
</TouchableHighlight>
|
|
</View>
|
|
</View>
|
|
);
|
|
}
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
marginTop: (Platform.OS === 'ios') ? 30 : 10,
|
|
flex: 1,
|
|
alignItems: 'center',
|
|
},
|
|
button: {
|
|
color: '#333333',
|
|
marginBottom: 15,
|
|
},
|
|
});
|
|
|
|
AppRegistry.registerComponent('Example', () => Example);
|