Skip to content

Instantly share code, notes, and snippets.

@himanshu717171
Created December 30, 2019 07:43
Show Gist options
  • Save himanshu717171/c460679f57d122915296180e80cffbc6 to your computer and use it in GitHub Desktop.
Save himanshu717171/c460679f57d122915296180e80cffbc6 to your computer and use it in GitHub Desktop.
Implementing Google Adsense in React Native Expo App
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"
}
});
@canali83
Copy link

its admob. not adsense

@Br3-ma
Copy link

Br3-ma commented Feb 8, 2025

This is not adsense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment