ammarahm-ed/react-native-admob-native-ads

Getting template ID error... {"code": 0, "domain": "com.google.android.gms.ads", "message": "Invalid template ID: -1"}

SagarG-Work-GIT opened this issue · 5 comments

STEP 1
AdManager.registerRepository({
name: 'imageAd',
adUnitId: "ca-app-pub-3940256099942544/2247696110",
numOfAds: 1,
nonPersonalizedAdsOnly: false,
videoOptions: {
mute: false,
},
expirationPeriod: 3600000, // in milliseconds (optional)
mediationEnabled: false,
}).then(result => {
console.log('registered: ', result);
});

STEP 2
const nativeAdViewRef = useRef();

React.useEffect(() => {
nativeAdViewRef.current?.loadAd();
}, []);

STEP 3
<NativeAdView
ref={nativeAdViewRef}
repository="imageAd"
style={{ height: 500, backgroundColor: 'green' }}
// enableTestMode
adChoicesPlacement="bottomLeft"
mediaAspectRatio="any"
onNativeAdLoaded={(e) => {
console.log(e);

    }}
    onAdLoaded={() => {
      console.log('ads loaded');
      
    }}
    onAdFailedToLoad={(err) => {
      console.log('failed load ==> ', err);
      
    }}
  >
   <View style={{ height: 400, backgroundColor: 'red' }}>

    </View>
  </NativeAdView>

==========================================================

Every time Im loading ads it is showing --- >
{"code": 0, "domain": "com.google.android.gms.ads", "message": "Invalid template ID: -1"}

Please share your ideas....

Facing same on real device. Any Update?

Kindly provide an example to reproduce the issue.

I got this problem also.
I use react-native-admob-native-ads and react-native-admob-native-ads to display interstitial Ad.
However, the native ad only works successfully the first time, which means it works after I install the App.
After I display the interstitial Ad, I restart the App. The native ad gets the error Invalid template ID: -1.
But the interstitial Ad still works well.

There is a native ad in a page, and also there is a button when a user clicks, it shows interstitial ad.
I'm using TestID for testing the Ads.

No matter, I tried on the Android simulator and the physical device.

Please help me.

I have fixed this problem with changing emulator API 31 to API 30.
If you have a different API like me, just change it to API 30 and try again.

@dev007github thanks for your help.