AI-generated Key Takeaways
-  Rewarded ads allow users to interact with ads in exchange for in-app rewards. 
-  Integrating rewarded ads involves loading an ad, optionally validating server-side verification callbacks, registering for callbacks, and displaying the ad to handle the reward event. 
-  Always test with dedicated test ad unit IDs to avoid account suspension. 
-  Implement GADFullScreenContentDelegateto receive notifications for ad presentation and dismissal events.
-  Display the ad using presentFromRootViewController:userDidEarnRewardHandler:and handle the reward within the handler.
Rewarded ads are ads that users have the option of interacting with in exchange for in-app rewards . This guide shows you how to integrate rewarded ads from AdMob into an iOS app. Read some customer success stories: case study 1 , case study 2 .
Prerequisites
- Complete the Get started guide .
Always test with test ads
When building and testing your apps, make sure you use test ads rather than live, production ads. Failure to do so can lead to suspension of your account.
The easiest way to load test ads is to use our dedicated test ad unit ID for iOS rewarded ads:
 ca-app-pub-3940256099942544/1712485313 
It's been specially configured to return test ads for every request, and you're free to use it in your own apps while coding, testing, and debugging. Just make sure you replace it with your own ad unit ID before publishing your app.
For more information about how Google Mobile Ads SDK test ads work, see Test Ads .
Implementation
The primary steps to integrate rewarded ads are as follows:
- Load an ad
- [Optional] Validate SSV callbacks
- Register for callbacks
- Display the ad and handle the reward event
Load an ad
Loading an ad is accomplished using the  load(adUnitID:request) 
 
method on the GADRewardedAd 
class.
Swift
  func 
  
 loadRewardedAd 
 () 
  
 async 
  
 { 
  
 do 
  
 { 
  
 rewardedAd 
  
 = 
  
 try 
  
 await 
  
 RewardedAd 
 . 
 load 
 ( 
  
 // Replace this ad unit ID with your own ad unit ID. 
  
 with 
 : 
  
 "ca-app-pub-3940256099942544/1712485313" 
 , 
  
 request 
 : 
  
 Request 
 ()) 
  
 rewardedAd 
 ?. 
 fullScreenContentDelegate 
  
 = 
  
 self 
  
 } 
  
 catch 
  
 { 
  
 print 
 ( 
 "Rewarded ad failed to load with error: 
 \( 
 error 
 . 
 localizedDescription 
 ) 
 " 
 ) 
  
 } 
 } 
  
 
 
SwiftUI
  import 
  
 GoogleMobileAds 
 class 
  
 RewardedViewModel 
 : 
  
 NSObject 
 , 
  
 ObservableObject 
 , 
  
 FullScreenContentDelegate 
  
 { 
  
 @ 
 Published 
  
 var 
  
 coins 
  
 = 
  
 0 
  
 private 
  
 var 
  
 rewardedAd 
 : 
  
 RewardedAd 
 ? 
  
 func 
  
 loadAd 
 () 
  
 async 
  
 { 
  
 do 
  
 { 
  
 rewardedAd 
  
 = 
  
 try 
  
 await 
  
 RewardedAd 
 . 
 load 
 ( 
  
 with 
 : 
  
 "ca-app-pub-3940256099942544/1712485313" 
 , 
  
 request 
 : 
  
 Request 
 ()) 
  
 rewardedAd 
 ?. 
 fullScreenContentDelegate 
  
 = 
  
 self 
  
 } 
  
 catch 
  
 { 
  
 print 
 ( 
 "Failed to load rewarded ad with error: 
 \( 
 error 
 . 
 localizedDescription 
 ) 
 " 
 ) 
  
 } 
  
 } 
  
 
 
Objective-C
  // Replace this ad unit ID with your own ad unit ID. 
 [ 
 GADRewardedAd 
  
 loadWithAdUnitID 
 : 
 @"ca-app-pub-3940256099942544/1712485313" 
  
 request 
 :[ 
 GADRequest 
  
 request 
 ] 
  
 completionHandler 
 : 
 ^ 
 ( 
 GADRewardedAd 
  
 * 
 ad 
 , 
  
 NSError 
  
 * 
 error 
 ) 
  
 { 
  
 if 
  
 ( 
 error 
 ) 
  
 { 
  
 NSLog 
 ( 
 @"Rewarded ad failed to load with error: %@" 
 , 
  
 [ 
 error 
  
 localizedDescription 
 ]); 
  
 return 
 ; 
  
 } 
  
 self 
 . 
 rewardedAd 
  
 = 
  
 ad 
 ; 
  
 self 
 . 
 rewardedAd 
 . 
 fullScreenContentDelegate 
  
 = 
  
 self 
 ; 
  
 }]; 
  
 
 
[Optional] Validate server-side verification (SSV) callbacks
Apps that require extra data in server-side
verification 
callbacks should use the
custom data feature of rewarded ads. Any string value set on a rewarded ad
object is passed to the custom_data 
query parameter of the SSV callback. If no
custom data value is set, the custom_data 
query parameter value won't be
present in the SSV callback.
The following code sample demonstrates how to set custom data on a rewarded ad object before requesting an ad:
Swift
Objective-C
Replace SAMPLE_CUSTOM_DATA_STRING with your custom data.
Register for callbacks
To receive notifications for presentation events, you must assign the GADFullScreenContentDelegate 
to the fullScreenContentDelegate 
property of the
returned ad:
Swift
  rewardedAd 
 ?. 
 fullScreenContentDelegate 
  
 = 
  
 self  
 
 . 
 swift 
 
 

