Close

How to add AdMob in React Native

Integration of AdMob in your React Native project is quite easy.

You can first install AdMob by using npm 

 

npm i react-native-admob

react-native link

 

inside your js file, import admob

import {AdMobBanner} from 'react-native-admob'

render()

{

return (

<View style={styles.adView}>

<AdMobBanner

adSize="banner"

adUnitID="ca-app-pub-7479592788394026/5011181590" //your admob id

testDevices={[AdMobBanner.simulatorId]}

//onAdFailedToLoad={error => console.error(error)}

/>

</View >

);

}

Where style is 

const styles = StyleSheet.create({

adView:

{

height: 50,

width: screenWidth, // get screen width by dimension

backgroundColor: 'white',

margin:20,

justifyContent: "center",

alignItems: "center",

},

});

 

You can download the complete working project from here.

 

For any kind of support related to React Native you can contact us at: support@triffort.com or sales@triffort.com

 

Triffort Technologies Pvt Ltd
www.triffort.com

 

0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

Comment

Name

Email

Social Comments
Go top