YMARewardedAdDelegate

Objective-C

@protocol YMARewardedAdDelegate <NSObject>

Swift

protocol YMARewardedAdDelegate : NSObjectProtocol

The protocol defines the methods of the delegate that tracks ads. Methods are called by an object of the YMARewardedAd class when its state changes.

  1. Methods
  2. -rewardedAd:didReward:
  3. -rewardedAdDidLoad:
  4. -rewardedAdDidFailToLoad:error:
  5. -rewardedAdWillLeaveApplication:
  6. -rewardedAdDidFailToPresent:error:
  7. -rewardedAdWillAppear:
  8. -rewardedAdDidAppear:
  9. -rewardedAdWillDisappear:
  10. -rewardedAdDidDisappear:
  11. -rewardedAdDidClick:
  12. -rewardedAd:willPresentScreen:
  13. -rewardedAd:didTrackImpressionWithData:

Methods

-rewardedAd:didReward:

Notifies that the user should be rewarded for viewing an ad (impression counted).

Declaration

Objective-C

- (void)rewardedAd:(nonnull YMARewardedAd *)rewardedAd
         didReward:(nonnull id<YMAReward>)reward;

Parameters

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

reward

The user’s reward (YMAReward).

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

reward

The user’s reward (YMAReward).

-rewardedAdDidLoad:

Notifies that the ad has been loaded successfully.

Declaration

Objective-C

- (void)rewardedAdDidLoad:(nonnull YMARewardedAd *)rewardedAd;

Swift

optional func rewardedAdDidLoad(_ rewardedAd: YMARewardedAd)

Parameters

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

-rewardedAdDidFailToLoad:error:

Notifies that the ad failed to load.

Declaration

Objective-C

- (void)rewardedAdDidFailToLoad:(nonnull YMARewardedAd *)rewardedAd
                          error:(nonnull NSError *)error;

Swift

optional func rewardedAdDidFail(toLoad rewardedAd: YMARewardedAd, error: Error)

Parameters

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

error

Information about the error (for details, see YMAAdErrorCode).

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

error

Information about the error (for details, see YMAAdErrorCode).

-rewardedAdWillLeaveApplication:

Notifies that the app will run in the background now because the user clicked on the ad and is about to switch to a different app (Phone, App Store, and so on).

Declaration

Objective-C

- (void)rewardedAdWillLeaveApplication:(nonnull YMARewardedAd *)rewardedAd;

Swift

optional func rewardedAdWillLeaveApplication(_ rewardedAd: YMARewardedAd)

Parameters

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

-rewardedAdDidFailToPresent:error:

Notifies that the ad can’t be displayed.

Declaration

Objective-C

- (void)rewardedAdDidFailToPresent:(nonnull YMARewardedAd *)rewardedAd
                             error:(nonnull NSError *)error;

Swift

optional func rewardedAdDidFail(toPresent rewardedAd: YMARewardedAd, error: Error)

Parameters

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

error

Information about the error (for details, see YMAAdErrorCode).

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

error

Information about the error (for details, see YMAAdErrorCode).

-rewardedAdWillAppear:

Called before the rewarded ad appears.

Declaration

Objective-C

- (void)rewardedAdWillAppear:(nonnull YMARewardedAd *)rewardedAd;

Swift

optional func rewardedAdWillAppear(_ rewardedAd: YMARewardedAd)

Parameters

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

-rewardedAdDidAppear:

Called after the rewarded ad appears.

Declaration

Objective-C

- (void)rewardedAdDidAppear:(nonnull YMARewardedAd *)rewardedAd;

Swift

optional func rewardedAdDidAppear(_ rewardedAd: YMARewardedAd)

Parameters

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

-rewardedAdWillDisappear:

Called before hiding the rewarded ad.

Declaration

Objective-C

- (void)rewardedAdWillDisappear:(nonnull YMARewardedAd *)rewardedAd;

Swift

optional func rewardedAdWillDisappear(_ rewardedAd: YMARewardedAd)

Parameters

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

-rewardedAdDidDisappear:

Called after hiding the rewarded ad.

Declaration

Objective-C

- (void)rewardedAdDidDisappear:(nonnull YMARewardedAd *)rewardedAd;

Swift

optional func rewardedAdDidDisappear(_ rewardedAd: YMARewardedAd)

Parameters

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

-rewardedAdDidClick:

Notifies that the user clicked on the ad.

Declaration

Objective-C

- (void)rewardedAdDidClick:(nonnull YMARewardedAd *)rewardedAd;

Swift

optional func rewardedAdDidClick(_ rewardedAd: YMARewardedAd)

Parameters

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

-rewardedAd:willPresentScreen:

Notifies that the in-app browser will be displayed.

Declaration

Objective-C

- (void)rewardedAd:(nonnull YMARewardedAd *)rewardedAd
    willPresentScreen:(nullable UIViewController *)viewController;

Swift

optional func rewardedAd(_ rewardedAd: YMARewardedAd, willPresentScreen viewController: Any!)

Parameters

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

viewController

Modal UIViewController (in-app browser).

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

viewController

Modal UIViewController (in-app browser).

-rewardedAd:didTrackImpressionWithData:

It’s called when an ad impression has been counted.

Declaration

Objective-C

- (void)rewardedAd:(nonnull YMARewardedAd *)rewardedAd
    didTrackImpressionWithData:(nullable id<YMAImpressionData>)impressionData;

Parameters

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

impressionData

Revenue data at the level of ad impressions.

rewardedAd

A reference to the object of the YMARewardedAd class that invoked the method.

impressionData

Revenue data at the level of ad impressions.