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.

  1. Properties
  2. adUnitID
  3. loaded
  4. delegate
  5. shouldOpenLinksInApp
  6. hasBeenPresented
  7. userID
  8. Methods
  9. -initWithAdUnitID:
  10. -load
  11. -loadWithRequest:
  12. -presentFromViewController:
  13. -presentFromViewController:dismissalBlock:

Properties

adUnitID

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 }

loaded

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 }

delegate

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 }

shouldOpenLinksInApp

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 }

hasBeenPresented

Notifies whether the ad was displayed.

Declaration

Objective-C

@property (nonatomic, readonly) BOOL hasBeenPresented;

Swift

var hasBeenPresented: Bool { get }

userID

Unique app user ID. Defaults to nil. Used for reward confirmation on the server side.

Declaration

Objective-C

@property (nonatomic, copy, nullable) NSString *userID;

Swift

var userID: String? { get set }

Methods

-initWithAdUnitID:

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.

-load

Preloads an ad. After this, use the -[YMARewardedAd presentFromViewController:] method to start showing the ad.

Declaration

Objective-C

- (void)load;

Swift

func load()

-loadWithRequest:

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 (YMAAdRequest).

request

Data for targeting (YMAAdRequest).

-presentFromViewController:

Displays ads after preloading.

Declaration

Objective-C

- (void)presentFromViewController:(nonnull UIViewController *)viewController;

Swift

func present(fromViewController viewController: Any!)

Parameters

viewController

An object of the UIViewController class, which is used to display a rewarded video ad.

viewController

An object of the UIViewController class, which is used to display a rewarded video ad.

-presentFromViewController:dismissalBlock:

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 UIViewController class, which is used to display a rewarded video ad.

dismissalBlock

A block of code that executes after the ad is shown.

viewController

An object of the UIViewController class, which is used to display a rewarded video ad.

dismissalBlock

A block of code that executes after the ad is shown.