How to close Rewarded AD automacticaly?

315 views
Skip to first unread message

Walker Daemon

unread,
Nov 13, 2023, 8:42:48 AM11/13/23
to Google Mobile Ads SDK Developers
Hi there

I have difficulties with close Rewared AD automatically.

I try to close AD after user earned reward, like in the OnUserEarnedRewardListener. But I cannot find any close or finish method in the instance of RewardItem or RewardedAd.

So is there any way to close it?

Best regards,
Walker

Mobile Ads SDK Forum Advisor

unread,
Nov 14, 2023, 7:03:27 AM11/14/23
to d4em0...@gmail.com, google-adm...@googlegroups.com

Hi Walker,

Thank you for contacting the Mobile Ads SDK Support team.

Upon reviewing your concern, I understand that you need to know about how to close Rewarded AD after the user earned a reward. To close a Rewarded Ad after a user has earned a reward, you can use the following code:

rewardedAd.onUserEarnedReward.listen((reward) {

  // Close the ad.

  rewardedAd.dispose();

});

The rewardedAd.show() method will show the Rewarded Ad. The 

rewardedAd.onUserEarnedReward event will be fired when the user earns a reward. The reward object will contain information about the reward that the user has earned. The rewardedAd.dispose() method will close the Rewarded Ad.

Here is an example of how to use this code:

import 'package:google_mobile_ads/google_mobile_ads.dart';

void main() {

  // Initialize the Mobile Ads SDK.

  MobileAds.initialize();

  // Create a RewardedAd object.

  RewardedAd rewardedAd = RewardedAd(

    adUnitId: 'ca-app-pub-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',

  );

  // Load the RewardedAd.

  rewardedAd.loadAd();

  // Listen for the RewardedAd event.

  rewardedAd.onUserEarnedReward.listen((reward) {

    // Close the ad.

    rewardedAd.dispose();

  });

}

Kindly refer to the Rewarded implementation documentation for more details about it.

Please reach out to us, if you need any further assistance.

 

This message is in relation to case "ref:!00D1U01174p.!5004Q02qBz7h:ref"

Thanks,
 
Google Logo Mobile Ads SDK Team

 

 



Reply all
Reply to author
Forward
0 new messages