I am getting error on this below code- Can't find variable showInterstitialAd(). How to use InterstitialAd properly, my BannerAd working properly but InterstitialAd not working.
Thanks in advance for your support.
import React, { useState, useEffect } from "react";
import { View, Button, Text, ScrollView, } from 'react-native';
import {
AppOpenAd, MaxAdContentRating, BannerAdSize, InterstitialAd,
RewardedAd, BannerAd, TestIds
} from 'react-native-google-mobile-ads';
admob()
.setRequestConfiguration({
// Update all future requests suitable for parental guidance
maxAdContentRating: MaxAdContentRating.PG,
// Indicates that you want your content treated as child-directed for purposes of COPPA.
tagForChildDirectedTreatment: true,
// Indicates that you want the ad request to be handled in a
// manner suitable for users under the age of consent.
tagForUnderAgeOfConsent: true,
})
.then(() => {
// Request config successfully set!
});
this.showInterstitialAd();
showInterstitialAd = () => {
const interstitialAd = InterstitialAd.createForAdRequest(TestIds.INTERSTITIAL);
interstitialAd.onAdEvent((type, error) => {
if (type === AdEventType.LOADED) {
interstitialAd.show();
}
});
interstitialAd.load();
}
const TestAds = ({ navigation }) => {
return (
<ScrollView>
<View>
<View style={{ marginTop: 20 }}>
<Text>
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
</Text>
</View>
</View>
</ScrollView>
)
}
export default TestAds