showOpenAppAd method

void showOpenAppAd()

<------------------------ Show AppOpenAd ------------------------>

Implementation

void showOpenAppAd() {
  if (_appOpenAd == null || _isShowingAd) {
    loadAppOpenAd(); // Load an ad if none is available or already showing
    return;
  }
  _isShowingAd = true;

  // Set the fullScreenContentCallback to handle ad events
  _appOpenAd!.fullScreenContentCallback = FullScreenContentCallback(
    onAdShowedFullScreenContent: (ad) {
      _isShowingAd = true;
      AdmobEasyLogger.info('$ad onAdShowedFullScreenContent');
    },
    onAdFailedToShowFullScreenContent: (ad, error) {
      AdmobEasyLogger.error('$ad failed to show full screen content: $error');
      _isShowingAd = false;
      ad.dispose();
      _appOpenAd = null;
      loadAppOpenAd(); // Load a new ad after failure
    },
    onAdDismissedFullScreenContent: (ad) {
      AdmobEasyLogger.info('$ad dismissed');
      _isShowingAd = false;
      ad.dispose();
      _appOpenAd = null;
      loadAppOpenAd(); // Preload a new ad after dismissal
    },
  );

  // Show the app open ad
  _appOpenAd!.show();
}