2

I'm trying to use Admob Rewarded Video in my React Native app.

Here is the code I am testing:

const advert = firebase.admob().rewarded('ca-app-pub-3940256099942544/5224354917');

const AdRequest = firebase.admob.AdRequest;
const request = new AdRequest();

// Load the advert with our AdRequest
advert.loadAd(request.build());

advert.on('onAdLoaded', () => {
  console.log('Advert ready to show.');
});

advert.on('onRewarded', (event) => {
  console.log('The user watched the entire video and will now be rewarded!', event);
});

if (advert.isLoaded()) {
  advert.show();
}
else {
  advert.on('onAdLoaded', () => {
    console.log('Advert ready to show.');
    advert.show();
  });
}

This is perfectly working when I execute it from the main screen of the app (root of the navigator), but not anymore after I move to an other screen by calling this.props.navigation.navigate('ScreenB');:

The ad is showing normally but I cannot skip, open or close it... The app gets stuck in this state.

I am currently testing on iOS simulator and I use the following config:

"react": "16.6.0-alpha.8af6728", "react-native": "^0.57.2", "react-native-firebase": "^5.1.0"

Am I missing something or is it a bug?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Bogy
  • 944
  • 14
  • 30

2 Answers2

0

Evertime when you want to show a banner you need to rebuild it again.

A single rewarded video instance can only be shown once. If you want to display another, create a new one.

 advert.loadAd(request.build());
Oyeme
  • 11,088
  • 4
  • 42
  • 65
0

You can try hiding the status bar when a fullscreen ad shows and bringing it back after it is closed.

Here is my code:

const [isStatusBarhiddden, setIsStatusBarhiddden] = useState(false);

const unsubscribeLoaded = rewardedInterstitial?.addAdEventListener(
  RewardedAdEventType.LOADED,
  () => {
    setIsStatusBarhiddden(true);
  },
);

const unsubscribeClosed = rewardedInterstitial?.addAdEventListener(
  AdEventType.CLOSED,
  () => {
    setIsStatusBarhiddden(false);
  },
);

return(
  <StatusBar hidden={isStatusBarhiddden} />
)
Md. Robi Ullah
  • 1,703
  • 3
  • 20
  • 32