Closed webby-genius closed 1 month ago
Hi @webby-genius, this code snippet looks fine in regards to your error. "The provided view controller is not being presented" error happens when the provided view controller view's window is nil
. Can you please share a minimal, reproducible example of your issue so we can take a closer look? Thanks
RewardedeAdsWidget().showRewardedOneTimeAd(
onAdDismissedFullScreenContent: (RewardedAd ad) async {
ad.dispose();
await RewardedeAdsWidget().createRewardedAd();
RewardedeAdsWidget().showRewardedOneTimeAd(
onAdDismissedFullScreenContent: (RewardedAd ad) async {
ad.dispose();
await RewardedeAdsWidget().createRewardedAd();
},
);
},
);
i need to rewarded ad show back to back 2 times and it's working fine in android device but in iOS device i found upper error when 2nd time ad show and this (2nd ad call) onAdDismissedFullScreenContent event as i show above code
Hi @webby-genius, the error you are experiencing is iOS-only so it is expected to work on Android. It also against policy to serve back-to-back rewarded ads. See number 2 of implementation requirements. You can only serve rewarded ads after a user has opted in to be served that particular ad. It's recommended to update your implementation and in doing so, you will avoid this error
1st time ads show perfectly but 2nd time get error (RewardedAd' onAdFailedToShowFullScreenContent: AdError(code: 17, domain: com.google.admob, message: The provided view controller is not being presented.)) then 3rd time ads show perfectly and it's sequent continue.. it's issue generate in iOS device only. android device wok perfectly
google_mobile_ads: ^5.1.0 3.19.6 -> Flutter SDK 3.3.4 -> (Flutter)Dart SDK
this is my code
static RewardedAd? rewardedAd; static int numRewardedLoadAttempts = 0; static int maxFailedLoadAttempts = 3; static int life = 0;
void createRewardedAd() { RewardedAd.load( adUnitId: AdHelper.rewardedAdUnitId, request: AdRequest(), rewardedAdLoadCallback: RewardedAdLoadCallback( onAdLoaded: (RewardedAd ad) { debugPrint('$ad loaded....Done'); rewardedAd = ad; numRewardedLoadAttempts = 0; }, onAdFailedToLoad: (LoadAdError error) { debugPrint('RewardedAd failed to load: $error'); rewardedAd = null; numRewardedLoadAttempts += 1; if (numRewardedLoadAttempts < maxFailedLoadAttempts) { createRewardedAd(); } }, ), ); }
void showRewardedOneTimeAd({void Function(RewardedAd)? onAdDismissedFullScreenContent}) { if (rewardedAd == null) { debugPrint('Warning: attempt to show rewarded before loaded.'); // Optionally, show a message to the user that the ad is not ready yet. return; }
}