AI-generated Key Takeaways
-
GADRewardedAd represents rewarded ads where users can interact with the ad for in-app rewards.
-
Key properties include
adUnitID,responseInfo, andadReward. -
serverSideVerificationOptionscan be set before presenting the ad for server-side reward verification. -
The ad can be loaded using either an ad unit ID and request or a server-to-server ad response string.
-
Methods are available to check if the ad can be presented and to present the ad from a view controller.
GADRewardedAd
@interface GADRewardedAd
: NSObject <GADAdMetadataProvider, GADFullScreenPresentingAd>A rewarded ad. Rewarded ads are ads that users have the option of interacting with in exchange for in-app rewards.
-
The ad unit ID.
Declaration
Swift
var adUnitID: String { get }Objective-C
@property (nonatomic, readonly, nonnull) NSString *adUnitID; -
Information about the ad response that returned the ad.
Declaration
Swift
var responseInfo: ResponseInfo { get }Objective-C
@property (nonatomic, readonly, nonnull) GADResponseInfo *responseInfo; -
The reward earned by the user for interacting with the ad.
Declaration
Swift
var adReward: AdReward { get }Objective-C
@property (nonatomic, readonly, nonnull) GADAdReward *adReward; -
Options specified for server-side user reward verification. Must be set before presenting this ad.
Declaration
Swift
@NSCopying var serverSideVerificationOptions: ServerSideVerificationOptions? { get set }Objective-C
@property (nonatomic, copy, nullable) GADServerSideVerificationOptions *serverSideVerificationOptions; -
Delegate for handling full screen content messages.
Declaration
Swift
weak var fullScreenContentDelegate: (any FullScreenContentDelegate)? { get set }Objective-C
@property (nonatomic, weak, nullable) id<GADFullScreenContentDelegate> fullScreenContentDelegate; -
Called when the ad is estimated to have earned money. Available for allowlisted accounts only.
Declaration
Swift
var paidEventHandler: GADPaidEventHandler? { get set }Objective-C
@property (nonatomic, copy, nullable) GADPaidEventHandler paidEventHandler; -
An identifier for a placement in reporting. This property must be set prior to presenting the ad.
Declaration
Swift
var placementID: Int64 { get set }Objective-C
@property (nonatomic) int64_t placementID; -
Loads a rewarded ad.
Declaration
Swift
class func load(with adUnitID: String, request: Request?) async throws -> RewardedAdObjective-C
+ (void)loadWithAdUnitID:(nonnull NSString *)adUnitID request:(nullable GADRequest *)request completionHandler: (nonnull GADRewardedAdLoadCompletionHandler)completionHandler;Parameters
adUnitIDAn ad unit ID created in the AdMob or Ad Manager UI.
requestAn ad request object. If nil, a default ad request object is used.
completionHandlerA handler to execute when the load operation finishes or times out.
-
Loads a rewarded ad.
Declaration
Swift
class func load(with adResponseString: String) async throws -> RewardedAdObjective-C
+ (void)loadWithAdResponseString:(nonnull NSString *)adResponseString completionHandler:(nonnull GADRewardedAdLoadCompletionHandler) completionHandler;Parameters
adResponseStringA server-to-server ad response string.
completionHandlerA handler to execute when the load operation finishes or times out.
-
Indicates whether the rewarded ad can be presented from the provided root view controller. Must be called on the main thread.
Declaration
Swift
@MainActor func canPresent(from rootViewController: UIViewController?) throwsObjective-C
- (BOOL)canPresentFromRootViewController: (nullable UIViewController *)rootViewController error:(NSError *_Nullable *_Nullable)error;Return Value
YESif the rewarded ad can be presented from the provided root view controller,NOotherwise. -
Presents the rewarded ad. Must be called on the main thread.
Declaration
Swift
@MainActor func present(from rootViewController: UIViewController?, userDidEarnRewardHandler: @escaping GADUserDidEarnRewardHandler)Objective-C
- (void)presentFromRootViewController: (nullable UIViewController *)rootViewController userDidEarnRewardHandler: (nonnull GADUserDidEarnRewardHandler)userDidEarnRewardHandler;Parameters
rootViewControllerA view controller to present the ad. If nil, attempts to present from the top view controller of the application’s main window.
userDidEarnRewardHandlerA handler to execute when the user earns a reward.