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.
{
"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.
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>
);
};
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();
}
};
export const App = () => {
const [loading, setLoading] = useState(true);
useEffect(() => {
initAdMob(() => setLoading(false));
}, [loading]);
...