import React, { useEffect } from 'react';
import {
NativeModules,
NativeEventEmitter
} from 'react-native';
const RNAdPopcornRewardVideoAdModule = NativeModules.RNAdPopcornRewardVideoAdModule;
function App(): JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
RNAdPopcornSSPModule.init();
RNAdPopcornRewardVideoAdModule.createInstance('YOUR_APP_KEY', 'PLACEMENT_ID');
RNAdPopcornRewardVideoAdModule.loadAd('PLACEMENT_ID');
return (
<SafeAreaView style={backgroundStyle}>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
/>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<Header />
</ScrollView>
</SafeAreaView>
);
}
componentDidMount() {
...
const eventEmitter = new NativeEventEmitter();
eventEmitter.addListener('OnRewardVideoAdLoaded', (event) => {
console.log('OnRewardVideoAdLoaded event : ' + event.placementId);
RNAdPopcornRewardVideoAdModule.showAd(event.placementId);
}
);
...
}