react-native-admob / admob

Admob for React Native with powerful hooks and components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Admob never loads

ahmtshn opened this issue · comments

Hi guys,

Admob never loads. Also, i can't see the error. adLoadError 'code' and 'message' fields always undefined.
Output: Ad failed to load with code undefined - undefined

Edited: i checked my installation twice. It's not wrong and my Google AdMob app status is 'Ready'. Also, i did use my Admob app before.


const FloatButton: FC<IFloatButton> = () => {
  const {show, load, adLoaded, reward, adPresented, adLoadError} =
    useRewardedAd(TestIds.REWARDED, {
      requestOptions: {
        requestNonPersonalizedAdsOnly: true,
      },
      loadOnDismissed: true,
    });

  useEffect(() => {
    load();
  }, []);

  useEffect(() => {
    console.log('AD LOADED  => ', adLoaded);
  }, [adLoaded]);

  useEffect(() => {
    console.log(
      `Ad failed to load with code ${adLoadError?.code} - ${adLoadError?.message}`,
    );
  }, [adLoadError]);

  useEffect(() => {
    if (adPresented) {
      console.log('WON');
    }
  }, [adPresented]);

  const showAd = () => {
    if (adLoaded) {
      show();
    } else {
      load();
    }
  };

  return (
    <TouchableOpacity onPress={showAd} style={styles.container}>
      <PlayIcon />
    </TouchableOpacity>
  );
};
commented

I have the same issue but only if I'm using TestIds so i decided to create real Ad Units in Admob, use it in the app and it's working now

This library is deprecated. Use react-native-google-mobile-ads instead.

Please migrate to the new library if you were using this library as this library is no longer maintained. Now more stronger features are available in the new library.