I got this error- TypeError: undefined is not a function (near '...interstitial.onAdEvent...')
How to implement interstitial ads?
I am using- npm i react-native-google-mobile-ads
Thank you in advance for your support.
import React, { useState, useEffect } from "react";
import { View, Button, Text, ScrollView, } from 'react-native';
import { AppOpenAd, InterstitialAd, RewardedAd, BannerAd, TestIds, AdEventType } from 'react-native-google-mobile-ads';
const TestAds = ({ navigation }) => {
useEffect(() => {
let interstitial = InterstitialAd.createForAdRequest(TestIds.INTERSTITIAL, {
requestNonPersonalizedAdsOnly: true,
keywords: ['fashion', 'clothing'],
});
let interstitialListener = interstitial.onAdEvent(type => {
if (type === AdEventType.LOADED){
interstitial.show();
}
});
interstitial.load();
return()=>{
interstitialListener=null;
};
}, []);
return (
<ScrollView>
<View>
<View style=>
<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
Via Active questions tagged javascript - Stack Overflow https://ift.tt/brOl3CT
Comments
Post a Comment