April 2021
Beginner to intermediate
506 pages
11h 57m
English
Similar to what you did in Use the AdMob Helper for Banner Ads, you’ll modify the AdMobHelper.swift file to support your rewarded ads.
Open the AdMobHelper.swift file, and in the AdMobHelper struct, add the following new static properties:
| | static var rewardAdReady = false |
| | static let rewardAdID = "ca-app-pub-3940256099942544/1712485313" // test |
Once again, the example here uses the Google test ID, but you’re welcome to use the ID you set up earlier—provided you follow Google’s recommendations for testing ads.
Next, add the file-private property below the _adBannerView property to hold the rewarded ad object:
| | fileprivate var _rewardedAd: GADRewardedAd? |
Finally, add the computed property ...
Read now
Unlock full access