Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

(ERROR) No ad to show #17

Closed
RenanNeitzel opened this issue Aug 20, 2021 · 3 comments
Closed

(ERROR) No ad to show #17

RenanNeitzel opened this issue Aug 20, 2021 · 3 comments

Comments

@RenanNeitzel
Copy link

RenanNeitzel commented Aug 20, 2021

Hi,

Anyone can help me, pls ?

I am using this library to show ads on my app. BannerAd and InterstitialAd works fine, but RewardedAd and RewardedInterstitialAd don't work for me.

I receive this error and I don't know what to do:

{
	"code": "E_AD_LOAD_FAILED",
	"domain": "com.google.admob",
	"message": "Request Error: No ad to show.",
	"nativeStackIOS": [
"0   Veek                                0x0000000102abc9f7 RCTJSErrorFromCodeMessageAndNSError + 135", 
"1   Veek                                0x000000010281e8fc __69-[RNAdMobRewarded requestAd:unitId:requestOptions:resolver:rejecter:]_block_invoke + 252", 
"2   Veek                                0x0000000102ff85b4 GAD_GADRewardedAd_x86_64_8_9_0 + 921", 
"3   Veek                                0x0000000102f67231 GAD_GADFullScreenAd_x86_64_8_9_0 + 1553", 
"4   libdispatch.dylib                   0x00000001178fe578 _dispatch_call_block_and_release + 12", 
"5   libdispatch.dylib                   0x00000001178ff74e _dispatch_client_callout + 8", 
"6   libdispatch.dylib                   0x000000011790db3f _dispatch_main_queue_callback_4CF + 1152", 
"7   CoreFoundation                      0x0000000114b168f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ +9",
"8   CoreFoundation                      0x0000000114b11169 __CFRunLoopRun + 2781",
"9   CoreFoundation                      0x0000000114b101a7 CFRunLoopRunSpecific + 567",
"10  GraphicsServices                    0x000000011913fd85 GSEventRunModal + 139",
"11  UIKitCore                           0x000000012408a4df -[UIApplication _run] + 912",
"12  UIKitCore                           0x000000012408f39c UIApplicationMain + 101",
"13  Veek                                0x000000010201e920 main + 112",
"14  libdyld.dylib                       0x000000011798dbbd start + 1",
"15  ???                                 0x0000000000000003 0x0 + 3"
],
	"userInfo": {
		"NSLocalizedDescription": "Request Error: No ad to show.",
		"gad_response_info": null
	}
}

On the same screen I display the banner without any problems, but the RewardedAd gives an error.

Screen Shot 2021-08-20 at 17 11 13

Snippet of my code:

import React from 'react';
import {RewardedAd} from '@react-native-admob/admob';

import {AdBanner} from '@~/components/atoms/AdBanner';
import * as Layout from '@~/components/organisms/layout';
import {Minimal} from '@~/components/templates/minimal';

export const CheckIn = ({navigation}: CheckInProps) => {
  const rewardId = Platform.OS === 'android'
     ? 'ca-app-pub-XXXXXXXXXXXXXXX/XXXXXXXX'
     : 'ca-app-pub-XXXXXXXXXXXXXXX/XXXXXXXX';

  const AdReward = RewardedAd.createAd(rewardId, {requestNonPersonalizedAdsOnly: false});

  useEffect(() => {
    AdReward.load();

    AdReward.addEventListener('adLoaded', (value: any) =>
      console.info('AD LOADED:   ', value),
    );

    AdReward.addEventListener('adFailedToLoad', (value: any) =>
      console.error('ERROR ON AD LOAD:  ', value),
    );

  }, [AdReward]);

  return (
    <Minimal
      theme="dark">
      <View style={styles.banner}>
        <AdBanner
          iosId="ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxxxx"
          androidId="ca-app-pub-xxxxxxxxxxxxxx/xxxxxxxxxxx"
        />
        <Layout.Padding>
          <Button
            transparent
            dark
            full
            onPress={() => {
              console.info('SHOW ADREWARDED');
              AdReward.show();
            }}>
            <Text>Fazer checkin</Text>
          </Button>
        </Layout.Padding>
      </View>
    </Minimal>
  );
};

I'm creating hook initialize() and running within App.js

My hook initialize:

const config = {
  maxAdContentRating: 'G',
  tagForChildDirectedTreatment: false,
  tagForUnderAgeConsent: false,
};

export const initAdMob = async (callback?: () => void | undefined) => {
  await AdMob.initialize()
    .then(value => {
      AdMob.setRequestConfiguration(config);
      console.info(value);
    })
    .catch(e => console.error(e));

  if (callback) {
    return callback();
  }
};

My execution:

export const App = () => {
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    initAdMob(() => setLoading(false));

  }, [loading]);

...
@wjaykim
Copy link
Collaborator

wjaykim commented Aug 20, 2021

This is maybe a problem related to your ad unit or your ad account. Find solution here

@RenanNeitzel
Copy link
Author

Perfect! I am now able to load the award-winning ads, but I am having another problem.
The "adLoaded" event returns that the video was loaded, but it does not display the video, returning the error:
"Possible Unhandled Promise Rejection
Error: Add is not ready."

Only after a while, I am able to view the video.
Is there another way to identify if the video is really ready to be shown or will it be necessary to create a correction for the return of this event?

@wjaykim
Copy link
Collaborator

wjaykim commented Sep 11, 2021

@RenanNeitzel Hi, sorry for late response. Please open new issue if you have other suggestions or bug to report.

@wjaykim wjaykim closed this as completed Sep 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants