-
-
Notifications
You must be signed in to change notification settings - Fork 153
Reward Ads
Elias edited this page Oct 27, 2020
·
2 revisions
Make sure you have initialize the plugin first. You can learn how to do this in the Installation Wiki Page
Showing Reward Ads
// First, create a reward ad
AdmobReward rewardAd = AdmobReward(
adUnitId: AdmobReward.testAdUnitId,
);
// Reward ads must be loaded before shown.
// Make sure to always load them ahead so they can be
// available to be shown immediately to the user
rewardAd.load();
// Check if the ad is loaded and then show it
if (await rewardAd.isLoaded) {
rewardAd.show();
}
// Finally, make sure you dispose the ad if you're done with it
rewardAd.dispose();
Listening to reward ads events works the same as with banners and interstitials, except that rewards have some additional events. One of them is the rewarded
event which you should listen to so you know whether your users have earned the reward or not:
AdmobReward rewardAd = AdmobReward(
adUnitId: AdmobReward.testAdUnitId,
listener: (AdmobAdEvent event, Map<String, dynamic> args) {
if (event == AdmobAdEvent.rewarded) {
print('User was rewarded!');
print('Reward type: ${args['type']}');
print('Reward amount: ${args['amount']}');
}
},
);