MASTAdViewDelegate Protocol Reference
Conforms to | NSObject |
Declared in | MASTAdView.h |
Overview
Protocal for interaction with the MASTAdView.
The entire protocol is optional. Some messages override default behavior and some are required to get full support for MRAID 2 ad content (saving calendar entries or pictures).
All messages are guaranteed to occur on the main thread. If any long running tasks are needed in reponse to any of the sent messages then they should be executed in a background thread to prevent and UI delays for the user.
Tasks
-
– MASTAdViewDidRecieveAd:
Sent after an ad has been downloaded and rendered.
-
– MASTAdView:didFailToReceiveAdWithError:
Sent if an error was encoutered while donloading or rendering an ad.
-
– MASTAdView:shouldOpenURL:
Sent when the ad will navigate to a clicked link.
-
– MASTAdViewCloseButtonPressed:
Sent when the close button is pressed by the user.
-
– MASTAdViewCustomCloseButton:
Implement to return a custom close button.
-
– MASTAdViewWillExpand:
Sent before the ad content is expanded in response to a richmedia expand event.
-
– MASTAdViewDidExpand:
Sent after the ad content is expanded in response to a richmedia expand event.
-
– MASTAdView:willResizeToFrame:
Sent before the ad content is resized in response to a richmedia resize event.
-
– MASTAdView:didResizeToFrame:
Sent after the ad content is resized in response to a richmedia resize event.
-
– MASTAdViewWillCollapse:
Sent before ad content is collaped if expanded or resized.
-
– MASTAdViewDidCollapse:
Sent after ad content is collaped if expanded or resized.
-
– MASTAdViewWillLeaveApplication:
Sent before the ad opens a URL that invokes another application (ex: Safari or App Store).
-
– MASTAdView:shouldLogEvent:ofType:
Sent when the ad view is about to log an event.
-
– MASTAdViewSupportsSMS:
Sent to allow developers to override SMS support.
-
– MASTAdViewSupportsPhone:
Sent to allow developers to override phone support.
-
– MASTAdViewSupportsCalendar:
Sent to allow developers to override calendar support.
-
– MASTAdViewSupportsStorePicture:
Sent to allow developers to override picture storing support.
-
– MASTAdView:didReceiveThirdPartyRequest:withParams:
Sent when the ad server receives a third party ad request from the ad network.
-
– MASTAdView:shouldPlayVideo:
Sent when an ad desires to play a video in an external player.
-
– MASTAdView:shouldSaveCalendarEvent:inEventStore:
Sent when a richmedia ad attempts to create a new calendar entry.
-
– MASTAdView:shouldSavePhotoToCameraRoll:
Sent when a richmedia ad attempts to save a picture to the camera roll.
-
– MASTAdView:didProcessRichmediaRequest:
Sent after the SDK process a richmedia event.
-
– MASTAdViewPresentationController:
Sent to allow the application to override the controller used to present modal controllers.
Instance Methods
MASTAdView:didFailToReceiveAdWithError:
Sent if an error was encoutered while donloading or rendering an ad.
- (void)MASTAdView:(MASTAdView *)adView didFailToReceiveAdWithError:(NSError *)error
Parameters
- adView
The MASTAdView instance sending the message.
- error
The error encountered while attempting to receive or render the ad.
Discussion
Sent if an error was encoutered while donloading or rendering an ad.
Declared In
MASTAdView.h
MASTAdView:didProcessRichmediaRequest:
Sent after the SDK process a richmedia event.
- (void)MASTAdView:(MASTAdView *)adView didProcessRichmediaRequest:(NSURLRequest *)event
Parameters
- adView
The MASTAdView instance sending the message.
- event
The NSURLRequest containing the event request.
Discussion
Sent after the SDK process a richmedia event.
Applications can use this to react to various events if necessary but the SDK will have already processed them as necessary (expanded in result of an expand request).
Warning: Developers should not attempt to implement the specified event. The SDK will have already processed the event with the SDK implementation.
See the IAB MRAID 2 specification on the event types.
Declared In
MASTAdView.h
MASTAdView:didReceiveThirdPartyRequest:withParams:
Sent when the ad server receives a third party ad request from the ad network.
- (void)MASTAdView:(MASTAdView *)adView didReceiveThirdPartyRequest:(NSDictionary *)properties withParams:(NSDictionary *)params
Parameters
- adView
The MASTAdView instance sending the message.
- properties
Properties of the request.
- params
Params for the third party SDK.
Discussion
Sent when the ad server receives a third party ad request from the ad network.
This can be implemented to invoke a third party ad SDK to render the requested content. The adView does no further processing of the third party request.
Declared In
MASTAdView.h
MASTAdView:didResizeToFrame:
Sent after the ad content is resized in response to a richmedia resize event.
- (void)MASTAdView:(MASTAdView *)adView didResizeToFrame:(CGRect)frame
Parameters
- adView
The MASTAdView instance sending the message.
- frame
The frame relative to the window where the resized content is displayed.
Discussion
Sent after the ad content is resized in response to a richmedia resize event.
The ad view itself is not resized, instead a new window is displayed with the resized ad content.
Declared In
MASTAdView.h
MASTAdView:shouldLogEvent:ofType:
Sent when the ad view is about to log an event.
- (BOOL)MASTAdView:(MASTAdView *)adView shouldLogEvent:(NSString *)event ofType:(MASTAdViewLogEventType)type
Parameters
- adView
The MASTAdView instance sending the message.
- event
The log event to log.
- type
The event type.
Return Value
YES
Log the event to NSLog().
NO
Omit logging the event to NSLog().
Discussion
Sent when the ad view is about to log an event.
Logging in the SDK is done with NSLog(). Implement and return NO
to log to application specific
log files. This message will only be sent if the event type is equal to or higher than the MASTADView
instance logLevel property.
Declared In
MASTAdView.h
MASTAdView:shouldOpenURL:
Sent when the ad will navigate to a clicked link.
- (BOOL)MASTAdView:(MASTAdView *)adView shouldOpenURL:(NSURL *)url
Return Value
YES
Allow the SDK to open the link with UIApplication’s openURL: or the internal browser.
NO
Ignore the request
Discussion
Sent when the ad will navigate to a clicked link.
Not implementing this method behaves as if YES
was returned.
Declared In
MASTAdView.h
MASTAdView:shouldPlayVideo:
Sent when an ad desires to play a video in an external player.
- (BOOL)MASTAdView:(MASTAdView *)adView shouldPlayVideo:(NSString *)videoURL
Parameters
- adView
The MASTAdView instance sending the message.
- videoURL
The URL string of the video to play.
Return Value
NO
Do not open the URL and play the video.
YES
Invoke UIApplication openURL: to play the video.
Discussion
Sent when an ad desires to play a video in an external player.
The default is to open the URL and play the video.
Developers can use an application player and return NO to play the video directly.
Declared In
MASTAdView.h
MASTAdView:shouldSaveCalendarEvent:inEventStore:
Sent when a richmedia ad attempts to create a new calendar entry.
- (BOOL)MASTAdView:(MASTAdView *)adView shouldSaveCalendarEvent:(EKEvent *)event inEventStore:(EKEventStore *)eventStore
Parameters
- adView
The MASTAdView instance sending the message.
- event
The event to save.
- eventStore
the store to save the event too.
Return Value
NO
Do not attempt to add the calendar event.
YES
Present the calendar event editor to the user to allow them to edit and save or cancel the event.
Discussion
Sent when a richmedia ad attempts to create a new calendar entry.
Application developers can implement the dialog directly if desired by capturing the event
and eventStore and returning nil
. If not implemented the SDK will ignore the request.
Declared In
MASTAdView.h
MASTAdView:shouldSavePhotoToCameraRoll:
Sent when a richmedia ad attempts to save a picture to the camera roll.
- (BOOL)MASTAdView:(MASTAdView *)adView shouldSavePhotoToCameraRoll:(UIImage *)image
Return Value
NO
Do not save the image to the camera roll.
YES
Attempt to save the image to the camera roll.
Discussion
Sent when a richmedia ad attempts to save a picture to the camera roll.
Application developers should implement this by prompting the user to save the image and then saving it directly and returning NO from this delegate method. If not implemented the image will NOT be saved to the camera roll.
Note: iOS 6 added privacy options for applications saving to the camera roll. The user will be
prompted by iOS on the first attempt at accessing the camera roll. If the user selects No then
pictures will not be saved to the camera roll even if this method is implemented and returns YES
.
Declared In
MASTAdView.h
MASTAdView:willResizeToFrame:
Sent before the ad content is resized in response to a richmedia resize event.
- (void)MASTAdView:(MASTAdView *)adView willResizeToFrame:(CGRect)frame
Parameters
- adView
The MASTAdView instance sending the message.
- frame
The frame relative to the window where the resized content is displayed.
Discussion
Sent before the ad content is resized in response to a richmedia resize event.
The ad view itself is not resized, instead a new window is displayed with the resized ad content.
Declared In
MASTAdView.h
MASTAdViewCloseButtonPressed:
Sent when the close button is pressed by the user.
- (void)MASTAdViewCloseButtonPressed:(MASTAdView *)adView
Parameters
- adView
The MASTAdView instance sending the message.
Discussion
Sent when the close button is pressed by the user.
This only occurs for the close button enabled with setCloseButton:afterDelay: or in the case of a interstitial richmedia ad that closes itself. It will not be sent for richmedia close buttons that collapse expanded or resized ads.
The common use case is for interstitial ads so the developer will know when to call closeInterstitial.
Declared In
MASTAdView.h
MASTAdViewCustomCloseButton:
Implement to return a custom close button.
- (UIButton *)MASTAdViewCustomCloseButton:(MASTAdView *)adView
Parameters
- adView
The MASTAdView instance sending the message.
Return Value
UIButton instance.
Discussion
Implement to return a custom close button.
This button will be used for richmedia ads if the richmedia ad does not indicate it has its own custom close button. It is also used if showCloseButton:afterDelay: enables the close button.
Warning: Do not return the same UIButton instance to different adView instances.
Warning: Developers should take care of adding action handlers to the button as it will be reused and may persist beyond the handlers lifetime.
Declared In
MASTAdView.h
MASTAdViewDidCollapse:
Sent after ad content is collaped if expanded or resized.
- (void)MASTAdViewDidCollapse:(MASTAdView *)adView
Parameters
- adView
The MASTAdView instance sending the message.
Discussion
Sent after ad content is collaped if expanded or resized.
Declared In
MASTAdView.h
MASTAdViewDidExpand:
Sent after the ad content is expanded in response to a richmedia expand event.
- (void)MASTAdViewDidExpand:(MASTAdView *)adView
Parameters
- adView
The MASTAdView instance sending the message.
Discussion
Sent after the ad content is expanded in response to a richmedia expand event.
The ad view itself is not expanded, instead a new window is displayed with the expanded ad content.
Declared In
MASTAdView.h
MASTAdViewDidRecieveAd:
Sent after an ad has been downloaded and rendered.
- (void)MASTAdViewDidRecieveAd:(MASTAdView *)adView
Parameters
- adView
The MASTAdView instance sending the message.
Discussion
Sent after an ad has been downloaded and rendered.
Declared In
MASTAdView.h
MASTAdViewPresentationController:
Sent to allow the application to override the controller used to present modal controllers.
- (UIViewController *)MASTAdViewPresentationController:(MASTAdView *)adView
Parameters
- adView
The MASTAdView instance sending the message.
Return Value
UIViewController to use as the presenting view controller for any SDK modal view controller.
Discussion
Sent to allow the application to override the controller used to present modal controllers.
The SDK by default will use the application’s rootViewController property to display modal dialogs. These include richmedia expand, internal browser and calendar event creation. To override using this controller implement this message and return the view controller that can be used to present modal view controllers.
Note: Application’s SHOULD have a rootViewController set but the iOS SDK will allow an application to run without one. If the application can not set up the rootViewController as expected then this method MUST be implemented to return a view controller that can be used to present modal dialogs. Without one certain SDK features will not work including showInterstitial, richmedia expand and the internal browser.
Declared In
MASTAdView.h
MASTAdViewSupportsCalendar:
Sent to allow developers to override calendar support.
- (BOOL)MASTAdViewSupportsCalendar:(MASTAdView *)adView
Parameters
- adView
The MASTAdView instance sending the message.
Return Value
NO
Informs richmedia ads that calendar access is not supported.
YES
Informs richmedia ads that calendar access is supported.
Discussion
Sent to allow developers to override calendar support.
Implement to indicate if calendar events can be created. The default behavior is to NOT allow calendar access.
On iOS 6 and later user permission is required to access the calendar. If this message is implemented and returns YES then the SDK will ask the user for permission during [MASTAdView update] or [MASTAdView updateWithTimeInterval:]. Refer to iOS EKEventStore documentation for more information.
Declared In
MASTAdView.h
MASTAdViewSupportsPhone:
Sent to allow developers to override phone support.
- (BOOL)MASTAdViewSupportsPhone:(MASTAdView *)adView
Parameters
- adView
The MASTAdView instance sending the message.
Return Value
NO
Informs richmedia ads that phone calls is not supported.
YES
Informs richmedia ads that phone calls is supported.
Discussion
Sent to allow developers to override phone support.
If the device supports phone dialling this message will be sent to allow the developer to override support. The default behavior is to allow phone dialing.
This message is not sent of the device does not support phone dialing.
Declared In
MASTAdView.h
MASTAdViewSupportsSMS:
Sent to allow developers to override SMS support.
- (BOOL)MASTAdViewSupportsSMS:(MASTAdView *)adView
Parameters
- adView
The MASTAdView instance sending the message.
Return Value
NO
Informs richmedia ads that SMS is not supported.
YES
Informs richmedia ads that SMS is supported.
Discussion
Sent to allow developers to override SMS support.
If the device supports SMS this message will be sent to allow the developer to override support. The default behavior is to allow SMS usage.
This message is not sent of the device does not support SMS.
Declared In
MASTAdView.h
MASTAdViewSupportsStorePicture:
Sent to allow developers to override picture storing support.
- (BOOL)MASTAdViewSupportsStorePicture:(MASTAdView *)adView
Parameters
- adView
The MASTAdView instance sending the message.
Return Value
NO
Informs richmedia ads that storing pictures is not supported.
YES
Informs richmedia ads that storing pictures is supported.
Discussion
Sent to allow developers to override picture storing support.
Implement to indicate if storing pictures is supported. The default behavior is to NOT allow storing of pictures.
Declared In
MASTAdView.h
MASTAdViewWillCollapse:
Sent before ad content is collaped if expanded or resized.
- (void)MASTAdViewWillCollapse:(MASTAdView *)adView
Parameters
- adView
The MASTAdView instance sending the message.
Discussion
Sent before ad content is collaped if expanded or resized.
Declared In
MASTAdView.h
MASTAdViewWillExpand:
Sent before the ad content is expanded in response to a richmedia expand event.
- (void)MASTAdViewWillExpand:(MASTAdView *)adView
Parameters
- adView
The MASTAdView instance sending the message.
Discussion
Sent before the ad content is expanded in response to a richmedia expand event.
The ad view itself is not expanded, instead a new window is displayed with the expanded ad content.
Declared In
MASTAdView.h
MASTAdViewWillLeaveApplication:
Sent before the ad opens a URL that invokes another application (ex: Safari or App Store).
- (void)MASTAdViewWillLeaveApplication:(MASTAdView *)adView
Parameters
- adView
The MASTAdView instance sending the message.
Discussion
Sent before the ad opens a URL that invokes another application (ex: Safari or App Store).
Declared In
MASTAdView.h