Created
December 30, 2019 07:43
-
-
Save himanshu717171/c460679f57d122915296180e80cffbc6 to your computer and use it in GitHub Desktop.
Implementing Google Adsense in React Native Expo App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component} from "react"; | |
import { Button, StyleSheet, Text, View } from "react-native"; | |
import { AdMobBanner, PublisherBanner } from 'expo-ads-admob'; | |
export default class App extends React.Component { | |
bannerError(e){ | |
alert(e); | |
} | |
render() { | |
return ( | |
<View style={styles.container}> | |
<Text>This is AdMobBanner</Text> | |
<AdMobBanner | |
bannerSize="banner" | |
adUnitID="ca-app-pub-3940256099942544/6300978111" | |
servePersonalizedAds | |
testDeviceID="861194041346858" //IMEI Number Of The Phone | |
onDidFailToReceiveAdWithError={ (e) => this.bannerError(e)} | |
/> | |
<Text>This is PublisherBanner</Text> | |
<PublisherBanner | |
bannerSize="largeBanner" | |
adUnitID="ca-app-pub-3940256099942544/6300978111" // Test ID, Replace with your-admob-unit-id | |
testDeviceID="861194041346858" | |
onDidFailToReceiveAdWithError={this.bannerError} | |
/> | |
</View> | |
); | |
} | |
} | |
App.navigationOptions = { | |
title: 'Admob', | |
headerStyle: { | |
backgroundColor: '#ff6666', | |
}, | |
headerTintColor: '#fff', | |
headerTitleStyle: { | |
fontWeight: 'bold', | |
fontSize:20 | |
}, | |
}; | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
backgroundColor: "#fff", | |
alignItems: "center", | |
justifyContent: "center" | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
its admob. not adsense