YMARewardedAd
Objective-C
@interface YMARewardedAd : NSObject
Swift
class YMARewardedAd : NSObject
The protocol defines the methods of the delegate that tracks rewarded ads. Methods are called by an object of the YMARewardedAd
class when its state changes.
- Properties
- adUnitID
- loaded
- delegate
- shouldOpenLinksInApp
- hasBeenPresented
- userID
- Methods
- -initWithAdUnitID:
- -load
- -loadWithRequest:
- -presentFromViewController:
- -presentFromViewController:dismissalBlock:
AdUnit ID is a unique identifier that is issued in the Partner interface and has the format R-M-XXXXXX-Y.
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull adUnitID;
Swift
var adUnitID: String { get }
Notifies that the ad is loaded and ready to be displayed. After the property takes the YES value, the -[YMARewardedAdDelegate rewardedAdDidLoad:]
delegate method is called.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL loaded;
Swift
var loaded: Bool { get }
An object that implements the YMARewardedAdDelegate
protocol that tracks ad lifecycle events.
Declaration
Objective-C
@property (nonatomic, weak, nullable) id<YMARewardedAdDelegate> delegate;
Swift
weak var delegate: YMARewardedAdDelegate? { get set }
Defines whether to open links in the app or in the browser installed on the device. The default value is NO
.
Declaration
Objective-C
@property (nonatomic) BOOL shouldOpenLinksInApp;
Swift
var shouldOpenLinksInApp: Bool { get set }
Notifies whether the ad was displayed.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL hasBeenPresented;
Swift
var hasBeenPresented: Bool { get }
Initializes an object of the YMARewardedAd
class with a rewarded video ad.
Declaration
Objective-C
- (nonnull instancetype)initWithAdUnitID:(nonnull NSString *)adUnitID;
Swift
init(adUnitID: String)
Parameters
adUnitID | AdUnit ID is a unique identifier that is issued in the Partner interface and has the format R-M-XXXXXX-Y. |
adUnitID | AdUnit ID is a unique identifier that is issued in the Partner interface and has the format R-M-XXXXXX-Y. |
Return Value
An object of the YMARewardedAd
class with a rewarded video ad.
Preloads an ad. After this, use the -[YMARewardedAd presentFromViewController:]
method to start showing the ad.
Declaration
Objective-C
- (void)load;
Swift
func load()
Preloads the ad by setting the data for targeting.
Declaration
Objective-C
- (void)loadWithRequest:(nullable YMAAdRequest *)request;
Swift
func load(with request: YMAAdRequest?)
Parameters
request | Data for targeting ( |
request | Data for targeting ( |
Displays ads after preloading.
Declaration
Objective-C
- (void)presentFromViewController:(nonnull UIViewController *)viewController;
Swift
func present(fromViewController viewController: Any!)
Parameters
viewController | An object of the |
viewController | An object of the |
Displays an ad after preloading it and performs some action immediately after showing the ad.
Declaration
Objective-C
- (void)presentFromViewController:(nonnull UIViewController *)viewController
dismissalBlock:(nullable void (^)(void))dismissalBlock;
Swift
func present(fromViewController viewController: Any!, dismissalBlock: (() -> Void)? = nil)
Parameters
viewController | An object of the |
dismissalBlock | A block of code that executes after the ad is shown. |
viewController | An object of the |
dismissalBlock | A block of code that executes after the ad is shown. |