MPRewardedVideoCustomEvent /3.5.0

@interface MPRewardedVideoCustomEvent : NSObject

The MoPub iOS SDK mediates third-party ad networks using custom events. The custom events are responsible for instantiating and manipulating objects in the third-party SDK and translating and communicating events from those objects back to the MoPub SDK by notifying a delegate.

MPRewardedVideoCustomEvent is a base class for custom events that support fullscreen rewarded video ads. By implementing subclasses of MPRewardedVideoCustomEvent you can enable the MoPub SDK to natively support a wide variety of third-party ad networks.

At runtime, the MoPub SDK will find and instantiate an MPRewardedVideoCustomEvent subclass as needed and invoke its -requestRewardedVideoWithCustomEventInfo:info:adMarkup: method.

Public Properties

NSDictionary /localExtras /+5.4.0

  • Description: An optional dictionary containing extra local data.

  • Declaration:

    @property (nonatomic, copy) NSDictionary * /localExtras;
    

id<MPRewardedVideoCustomEventDelegate> /delegate /+3.5.0

  • Description: Instances of your custom subclass of MPRewardedVideoCustomEvent will have an MPRewardedVideoCustomEventDelegate delegate. You use this delegate to communicate ad events back to the MoPub SDK.

  • Declaration:

    @property (nonatomic, weak) id<MPRewardedVideoCustomEventDelegate> /delegate;
    

Public Methods

Requesting and Displaying a Rewarded Video Ad

- /requestRewardedVideoWithCustomEventInfo:info: /+5.0.0-5.10.0

  • Description: DEPRECATED AS OF v.5.10.0. Instead use - requestRewardedVideoWithCustomEventInfo:info:adMarkup:

    Called when the MoPub SDK requires a new rewarded video ad. When the MoPub SDK receives a response indicating it should load a custom event, it will send this message to your custom event class. Your implementation of this method should load a rewarded video ad from a third-party ad network. The default implementation of this method does nothing. Subclasses must override this method and implement code to load a rewarded video here.

  • Declaration:

    - (void)requestRewardedVideoWithCustomEventInfo:(NSDictionary *)info;
    
  • Parameters:

    • info: A dictionary containing additional custom data associated with a given custom event request. This data is configurable on the MoPub website, and may be used to pass dynamic information, such as publisher IDs.

- /requestRewardedVideoWithCustomEventInfo:info:adMarkup: /+5.10.0

  • Description: Called when the MoPub SDK requires a new rewarded video ad. When the MoPub SDK receives a response indicating it should load a custom event, it will send this message to your custom event class. Your implementation of this method should load an rewarded video ad from a third-party ad network. The default implementation of this method does nothing. Subclasses must override this method and implement code to load a rewarded video here.

  • Declaration:

    - (void)requestRewardedVideoWithCustomEventInfo:(NSDictionary *)info adMarkup:(NSString *)adMarkup;
    
  • Parameters:

    • info: A dictionary containing additional custom data associated with a given custom event request. This data is configurable on the MoPub website, and may be used to pass dynamic information, such as publisher IDs.

    • adMarkup: An optional ad markup to use.

- /hasAdAvailable /+3.5.0

  • Description: Called when the MoPub SDK wants to know if an ad is currently available for the ad network. This call is typically invoked when the application wants to check whether an ad unit has an ad ready to display. Subclasses must override this method and implement coheck whether or not a rewarded vidoe ad is available for presentation.

  • Declaration:

    - (BOOL)hasAdAvailable;
    
  • Parameters: None.

- /presentRewardedVideoFromViewController: /+3.5.0

  • Description: Called when the rewarded video should be displayed. This message is sent sometime after a rewarded video has been successfully loaded, as a result of your code calling -MPRewardedVideo presentRewardedVideoAdForAdUnitID:fromViewController:.

    Your implementation of this method should present the rewarded video ad from the specified view controller. The default implementation of this method does nothing. Subclasses must override this method and implement code to display a rewarded video here. If you decide to opt out of automatic impression tracking, you should place your manual calls to -trackImpression in this method to ensure correct metrics.

  • Declaration:

    - (void)presentRewardedVideoFromViewController:(UIViewController *)viewController;
    
  • Parameters:

    • viewController: The controller to use to present the rewarded video modally.

Impression and Click Tracking

- /enableAutomaticImpressionAndClickTracking /+3.5.0

  • Description: Override to opt out of automatic impression and click tracking. By default, the MPRewardedVideoCustomEventDelegate will automatically record impressions and clicks in response to the appropriate callbacks. You may override this behavior by implementing this method to return NO.

    Important: If you do this, you are responsible for calling the -trackImpression and -trackClick methods on the custom event delegate. Additionally, you should make sure that these methods are only called once per ad.

  • Declaration:

    - (BOOL)enableAutomaticImpressionAndClickTracking;
    
  • Parameters: None.

- /handleAdPlayedForCustomEventNetwork /+3.5.0

  • Description: Override this method to handle when an ad was played for this custom event’s network, but under a different ad unit ID. Due to the way ad mediation works, two ad units may load the same ad network for displaying ads. When one ad unit plays an ad, the other ad unit may need to update its state and notify the application an ad may no longer be available as it may have already played. If an ad becomes unavailable for this custom event, call -rewardedVideoDidExpireForCustomEvent: to notify the application that an ad is no longer available. This method will only be called if your custom event has reported that an ad had successfully loaded. The default implementation of this method does nothing. Subclasses must override this method and implement code to handle when the custom event is no longer needed by the rewarded video system.

  • Declaration:

    - (void)handleAdPlayedForCustomEventNetwork;
    
  • Parameters: None.

- /handleCustomEventInvalidated /+3.5.0

  • Description: Override this method to handle when the custom event is no longer needed by the rewarded video system. This method is called once the rewarded video system no longer references your custom event. This method is provided as you may have a centralized object holding onto this custom event. If that is the case and your centralized object no longer needs the custom event, then you should remove the custom event from the centralized object in this method causing the custom event to deallocate. See MPAdColonyRewardedVideoCustomEvent for an example of how and why this method is used. Implementation of this method is not necessary if you do not hold any extra references to it. -dealloc will still be called. However, it is expected you will need to override this method to prevent memory leaks. It is safe to override with nothing if you believe you will not leak memory.

  • Declaration:

    - (void)handleCustomEventInvalidated;
    
  • Parameters: None.

Last updated May 06, 2020

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2020 MoPub (a division of Twitter, Inc.)