Skip to content

Instantly share code, notes, and snippets.

@EHakobyan
Created April 28, 2018 09:56
Show Gist options
  • Save EHakobyan/467d8150ac96c5e011147b1906e01777 to your computer and use it in GitHub Desktop.
Save EHakobyan/467d8150ac96c5e011147b1906e01777 to your computer and use it in GitHub Desktop.
const advert = firebase.admob().rewarded('ca-app-pub-4796389498971323~7794037532');
class HomeScreen extends PureComponent {
componentDidMount() {
const AdRequest = firebase.admob.AdRequest;
const request = new AdRequest();
advert.loadAd(request.build());
console.log(firebase)
advert.on('onAdLoaded', () => {
alert('Advert ready to show.');
});
}
showAd = () => {
if (advert.isLoaded()) {
advert.show();
} else {
alert('not loaded')
}
}
render() {
return (
<View style={styles.container}>
<Button title="Show ad" onPress={this.showAd}/>
<Button title="Sign out :)" onPress={this._signOutAsync}/>
{firebase.admob.nativeModuleExists && <Text style={styles.module}>Admob</Text>}
</View>
);
}
_showMoreApp = () => {
this.props.navigation.navigate('Other');
};
_signOutAsync = async () => {
await AsyncStorage.clear();
this.props.navigation.navigate('Auth');
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment