GADRewardedAd
@interface GADRewardedAd : NSObject
A rewarded ad. Rewarded ads are ads that users have the option of interacting with in exchange for in-app rewards. See https://developers.google.com/admob/ios/rewarded-ads to get started.
-
Initializes a rewarded ad with the provided ad unit ID. Create ad unit IDs using the AdMob website for each unique ad placement in your app. Unique ad units improve targeting and statistics.
Example AdMob ad unit ID: @“ca-app-pub-3940256099942544/1712485313”
Declaration
Swift
init(adUnitID: String)
Objective-C
- (nonnull instancetype)initWithAdUnitID:(nonnull NSString *)adUnitID;
-
Requests an rewarded ad and calls the provided completion handler when the request finishes.
Declaration
Swift
func load(_ request: GADRequest?, completionHandler: GADRewardedAdLoadCompletionHandler? = nil)
Objective-C
- (void)loadRequest:(nullable GADRequest *)request completionHandler: (nullable GADRewardedAdLoadCompletionHandler)completionHandler;
-
The ad unit ID.
Declaration
Swift
var adUnitID: String { get }
Objective-C
@property (readonly, nonatomic, nonnull) NSString *adUnitID;
-
Indicates whether the rewarded ad is ready to be presented.
Declaration
Swift
var isReady: Bool { get }
Objective-C
@property (readonly, getter=isReady, nonatomic) BOOL ready;
-
Information about the ad response that returned the current ad or an error. Nil until the first ad request succeeds or fails.
Declaration
Swift
var responseInfo: GADResponseInfo? { get }
Objective-C
@property (readonly, nonatomic, nullable) GADResponseInfo *responseInfo;
-
The reward earned by the user for interacting with a rewarded ad. Is nil until the ad has successfully loaded.
Declaration
Swift
var reward: GADAdReward? { get }
Objective-C
@property (readonly, nonatomic, nullable) GADAdReward *reward;
-
Options specified for server-side user reward verification.
Declaration
Swift
var serverSideVerificationOptions: GADServerSideVerificationOptions? { get set }
Objective-C
@property (nonatomic, nullable) GADServerSideVerificationOptions *serverSideVerificationOptions;
-
The loaded ad’s metadata. Is nil if no ad is loaded or the loaded ad doesn’t have metadata. Ad metadata may update after loading. Use the rewardedAdMetadataDidChange: delegate method on GADRewardedAdMetadataDelegate to listen for updates.
Declaration
Swift
var adMetadata: [GADAdMetadataKey : Any]? { get }
Objective-C
@property (readonly, nonatomic, nullable) NSDictionary<GADAdMetadataKey, id> *adMetadata;
-
Delegate for ad metadata changes.
Declaration
Swift
weak var adMetadataDelegate: GADRewardedAdMetadataDelegate? { get set }
Objective-C
@property (nonatomic, nullable) id<GADRewardedAdMetadataDelegate> adMetadataDelegate;
-
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 (copy, nonatomic, nullable) GADPaidEventHandler paidEventHandler;
-
Returns whether the rewarded ad can be presented from the provided root view controller. Sets the error out parameter if the rewarded ad can’t be presented. Must be called on the main thread.
Declaration
Swift
func canPresent(fromRootViewController rootViewController: UIViewController) throws
Objective-C
- (BOOL)canPresentFromRootViewController: (nonnull UIViewController *)rootViewController error:(NSError *_Nullable *_Nullable)error;
-
Presents the rewarded ad with the provided view controller and rewarded delegate to call back on various intermission events. The delegate is strongly retained by the receiver until a terminal delegate method is called. Terminal methods are -rewardedAd:didFailToPresentWithError: and -rewardedAdDidClose: of GADRewardedAdDelegate.
Declaration
Swift
func present(fromRootViewController viewController: UIViewController, delegate: GADRewardedAdDelegate)
Objective-C
- (void)presentFromRootViewController:(nonnull UIViewController *)viewController delegate: (nonnull id<GADRewardedAdDelegate>)delegate;
-
Deprecated. Use responseInfo.adNetworkClassName instead.
Declaration
Swift
var adNetworkClassName: String? { get }
Objective-C
@property (readonly, copy, nonatomic, nullable) NSString *adNetworkClassName;