We are developing using expo.
And… Used the ‘react-native-google-mobile-ads’
It looks good in the simulator, but it is not visible in the actual device.
However, it only appears once in a while.
Both ios and android are the same.
Is it because there is no SKAdNetwork setting?
Or maybe I’m missing some other setting or it’s a code error, I don’t know.
Please
Below is the app.json / eas.json / application code
app.json
{
"expo": {
~~~
},
"react-native-google-mobile-ads": {
"android_app_id": "ca-app-pub-3564826187055814~xxxxxxxx", //example
"ios_app_id": "ca-app-pub-3564826187055814~xxxxxxxx" //example
}
}
eas.json
{
"cli": {
"version": ">= 3.14.0"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal",
"ios": {
"simulator": true
}
},
"preview": {
"distribution": "internal"
},
"production": {
"autoIncrement": true
}
},
"submit": {
"production": {}
}
}
Application Code
import React from 'react';
import {StyleSheet, SafeAreaView, Platform} from 'react-native';
import {BannerAd, BannerAdSize, TestIds} from 'react-native-google-mobile-ads';
const adUnitId = __DEV__
? TestIds.BANNER
: Platform.OS === 'ios'
? 'ca-app-pub-3564826187055814/~~~~~~'
: 'ca-app-pub-3564826187055814/~~~~~~';
export function Ad() {
return (
<SafeAreaView style={styles.root}>
<BannerAd
unitId={adUnitId}
size={BannerAdSize.ANCHORED_ADAPTIVE_BANNER}
requestOptions={{
requestNonPersonalizedAdsOnly: true,
}}
/>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
root: {
display: 'flex',
width: '100%',
alignItems: 'center',
justifyContent: 'center',
},
});