react-native-admob-native-ads icon indicating copy to clipboard operation
react-native-admob-native-ads copied to clipboard

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

Open SagarG-Work-GIT opened this issue 2 years ago • 4 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....

SagarG-Work-GIT avatar Oct 29 '23 18:10 SagarG-Work-GIT

Facing same on real device. Any Update?

RoyalBosS-Ayush avatar Nov 08 '23 13:11 RoyalBosS-Ayush

Kindly provide an example to reproduce the issue.

ammarahm-ed avatar Dec 06 '23 03:12 ammarahm-ed

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.

aeolus1217 avatar Mar 17 '24 07:03 aeolus1217

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.

mustafaerken avatar Mar 31 '24 14:03 mustafaerken