MASTAdView Class Reference
Inherits from | UIView |
Declared in | MASTAdView.h |
Overview
Renders text, image and richmedia ads.
TODO: Include more information here and possibly a quick sample.
The -ObjC linker option is required when including the MASTAdView SDK.
Tasks
Other Methods
-
+ version
Returns the MASTAdView SDK’s version.
Initialization
-
– initWithFrame:
Initilizes an inline instance of the ad view.
-
– initInterstitial
Initializes an interstital instance of the ad view.
-
placementType
Returns the placement type for the instance.
property
Required configuration
-
site
Specifies the site for the ad network.
property -
zone
Specifies the zone for the ad network.
property
Optional configuration
-
adServerURL
Specifies the URL of the ad server.
property -
adRequestParameters
Allows setting extra server parameters.
property -
useInternalBrowser
Set to enable the use of the internal browser for opening ad content. Defaults to
propertyNO
. -
delegate
Sets the MASTAdViewDelegate delegate receiever for the ad view.
property
Updating and resetting ad content
-
– update
Issues an immediate ad update and cancles any existing ad update.
-
– updateWithTimeInterval:
Issues an immediate ad update and cancels any pending ad update. Will automatically update every interval seconds.
-
– reset
Restates the instance to its default state.
-
– removeContent
Removes any displayed ad content and any associated state.
Controlling interstitial presentation
-
– showInterstitial
Shows and closes the interstitial view.
-
– showInterstitialWithDuration:
Shows the interstitial and automatically closes after the specified duration.
-
– closeInterstitial
Closes the interstitial.
Close button support
-
– showCloseButton:afterDelay:
Shows a close button after the specified delay after the ad is rendered.
Location detection support
-
locationDetectionEnabled
Returns the enablement status of location detection.
property -
– setLocationDetectionEnabled:
Used to enable or disable location detection.
-
– setLocationDetectionEnabledWithPupose:significantUpdating:distanceFilter:desiredAccuracy:
Used to enable location detection with control over how the location is acquired.
Ad containers
-
labelView
Text ad container.
property -
imageView
Image ad container.
property -
webView
Web view ad container.
property -
expandView
Richmedia expand view container.
property -
resizeView
Richmedia resize view container.
property
Test content, logging and debugging
-
test
Instructs the ad server to return test ads for the configured site/zone.
property -
logLevel
Specifies the log level. All logging is via NSLog().
property -
– renderWithAdDescriptor:
Renders an ad directly without downloading it from the ad network.
Properties
adRequestParameters
Allows setting extra server parameters.
@property (nonatomic, readonly) NSMutableDictionary *adRequestParameters
Discussion
Allows setting extra server parameters.
The SDK will set various parameters based on configuration and other options.
For more information see http://developer.moceanmobile.com/Mocean_Ad_Request_API.
Warning: All parameter key and values must be NSString instances.
Declared In
MASTAdView.h
adServerURL
Specifies the URL of the ad server.
@property (nonatomic, copy) NSString *adServerURL
Discussion
Specifies the URL of the ad server.
Declared In
MASTAdView.h
delegate
Sets the MASTAdViewDelegate delegate receiever for the ad view.
@property (nonatomic, assign) id<MASTAdViewDelegate> delegate
Discussion
Sets the MASTAdViewDelegate delegate receiever for the ad view.
Warning: Proper reference management practices should be observed when using delegates.
Warning: Ensure that the delegate is set to nil prior to releasing the ad view’s instance.
Declared In
MASTAdView.h
expandView
Richmedia expand view container.
@property (nonatomic, readonly) UIView *expandView
Discussion
Richmedia expand view container.
This view is the container used to hold the view to be expanded. For richmedia ads that request an expand this will contain the UIWebView. This doesn’t include richmedia ads that expand with another creative (two part expand).
Warning: Do not attempt to move or affect the relationship of the view within its superview.
Declared In
MASTAdView.h
imageView
Image ad container.
@property (nonatomic, readonly) UIImageView *imageView
Discussion
Image ad container.
This can be accessed to modify how the image is handled.
Warning: Do not attempt to move or affect the relationship of the view within its superview.
Declared In
MASTAdView.h
labelView
Text ad container.
@property (nonatomic, readonly) UILabel *labelView
Discussion
Text ad container.
This can be accessed to modify how text is rendered such as font size, color, background color, etc…
Warning: Do not attempt to move or affect the relationship of the view within its superview.
Declared In
MASTAdView.h
locationDetectionEnabled
Returns the enablement status of location detection.
@property (nonatomic, readonly) BOOL locationDetectionEnabled
Discussion
Returns the enablement status of location detection.
May return NO
even if one of the setLocationDetectionEnabled methods was used
to enable it. This can happen if the device doesn’t support location enablement
or if the user has denied location permissions to the application. Note however
that this property should not be used to determine either of those cases for the
application.
Declared In
MASTAdView.h
logLevel
Specifies the log level. All logging is via NSLog().
@property (nonatomic, assign) MASTAdViewLogEventType logLevel
Discussion
Specifies the log level. All logging is via NSLog().
Declared In
MASTAdView.h
placementType
Returns the placement type for the instance.
@property (nonatomic, readonly) MASTAdViewPlacementType placementType
Discussion
Returns the placement type for the instance.
This is set based on how the instance was initialized.
See Also
Declared In
MASTAdView.h
resizeView
Richmedia resize view container.
@property (nonatomic, readonly) UIView *resizeView
Discussion
Richmedia resize view container.
This view is the container used to render resized richmedia ad it requests to resize.
Warning: Do not attempt to move or affect the relationship of the view within its superview.
Declared In
MASTAdView.h
site
Specifies the site for the ad network.
@property (nonatomic, assign) NSInteger site
Discussion
Specifies the site for the ad network.
Declared In
MASTAdView.h
test
Instructs the ad server to return test ads for the configured site/zone.
@property (nonatomic, assign) BOOL test
Discussion
Instructs the ad server to return test ads for the configured site/zone.
Warning: This should never be set to YES
for application releases.
Declared In
MASTAdView.h
useInternalBrowser
Set to enable the use of the internal browser for opening ad content. Defaults to NO
.
@property (nonatomic, assign) BOOL useInternalBrowser
Discussion
Set to enable the use of the internal browser for opening ad content. Defaults to NO
.
Declared In
MASTAdView.h
webView
Web view ad container.
@property (nonatomic, strong) UIWebView *webView
Discussion
Web view ad container.
This can be modified to change aspects of the web view such as background color, etc..
Warning: Do not attempt to move or affect the relationship of the view within its superview.
Warning: Do not attempt to change the delegate or affect how content is rendered as this may interfere with richmedia ads.
Declared In
MASTAdView.h
Instance Methods
closeInterstitial
Closes the interstitial.
- (void)closeInterstitial
Discussion
Closes the interstitial.
Declared In
MASTAdView.h
initInterstitial
Initializes an interstital instance of the ad view.
- (id)initInterstitial
Discussion
Initializes an interstital instance of the ad view.
The view is NOT intended to be used inline with other content or added to other views. Instead use the interstitial methods to show and close the full screen view.
Declared In
MASTAdView.h
initWithFrame:
Initilizes an inline instance of the ad view.
- (id)initWithFrame:(CGRect)frame
Parameters
- frame
The area to place the view.
Discussion
Initilizes an inline instance of the ad view.
The view can be added to other views as with any other UIView object. The frame is used to determine the size of the ad in the requested to the ad server. If not known at initialization time, ensure that the view’s frame is set prior to calling update.
Declared In
MASTAdView.h
removeContent
Removes any displayed ad content and any associated state.
- (void)removeContent
Discussion
Removes any displayed ad content and any associated state.
-Collapses any expanded or resized richmedia ads. -Closes interstitial.
Unlike reset, it does not reset the instance to it’s default state.
Declared In
MASTAdView.h
renderWithAdDescriptor:
Renders an ad directly without downloading it from the ad network.
- (void)renderWithAdDescriptor:(MASTMoceanAdDescriptor *)adDescriptor
Parameters
- adDescriptor
The ad descriptor to render.
Discussion
Renders an ad directly without downloading it from the ad network.
An update in progress due to update or updateWithTimeInterval: will override any ad set with this method. Call reset prior to calling this if update was used to download an ad from the ad network.
Warning: This not intended to be used in application releases.
Declared In
MASTAdView.h
reset
Restates the instance to its default state.
- (void)reset
Discussion
Restates the instance to its default state.
-Stops updates and cancels the update interval. -Stops location detection. -Collapses any expanded or resized richmedia ads. -Closes interstitial. -Closes internal ad browser.
Should be sent before releasing the instance if another object may be retaining it such as a superview or list. This allows the application to suspend ad updating and interaction activities to allow other application activitis to occur. After responding to other activities update or updateWithTimeInterval: can be sent again to resume ad updates.
Warning: If the project is using ARC (automatic reference counting) this MUST be called to cancel internal timers. If not the main NSRunLoop will retain a reference to the MASTAdView instance and continue invoking its timers.
Warning: Does not reset the delegate.
Declared In
MASTAdView.h
setLocationDetectionEnabled:
Used to enable or disable location detection.
- (void)setLocationDetectionEnabled:(BOOL)enabled
Parameters
- enabled
YES
to enable location detection with defaults,NO
to disable location detection.
Discussion
Used to enable or disable location detection.
Enabling location detection makes use of the devices location services to set the lat and long server properties that get sent with each ad request.
Note that it could take time to acquire the location so an immediate update call after location detection enablement may not include the location in the ad network request.
A call to reset will stop location detection.
When enabling location detection with this method the most power efficient options are used based on the devices capabilities. To specify more control over location options enable with setLocationDetectionEnabledWithPurpose:…
Declared In
MASTAdView.h
setLocationDetectionEnabledWithPupose:significantUpdating:distanceFilter:desiredAccuracy:
Used to enable location detection with control over how the location is acquired.
- (void)setLocationDetectionEnabledWithPupose:(NSString *)purpose significantUpdating:(BOOL)significantUpdating distanceFilter:(CLLocationDistance)distanceFilter desiredAccuracy:(CLLocationAccuracy)desiredAccuracy
Parameters
- purpose
Message to present to the user as to why location is being used. Can be nil.
- significantUpdating
If set to
YES
uses the startMonitoringSignificantLocationChanges if available on the device. If not available then this parameter is ignored. When available and set toYES
this parameter causes the distanceFilter and desiredAccuracy parameters to be ignored. If set toNO
then startUpdatingLocation is used and the distanceFilter and desiredAccuracy parameters are applied.
- distanceFilter
Amount of distance used to trigger updates.
- desiredAccuracy
Acuracy needed for updates.
Discussion
Used to enable location detection with control over how the location is acquired.
Warning: It is possible to configure location detection to use significant power and reduce battery life of the device. For most applications where location detection is desired use setLocationDetectionEnabled: for optimal battery life based on the device’s capabilities.
See Also
CLLocationManager for reference on the purpose, distanceFilter and desiredAccuracy parameters.
Declared In
MASTAdView.h
showCloseButton:afterDelay:
Shows a close button after the specified delay after the ad is rendered.
- (void)showCloseButton:(BOOL)showCloseButton afterDelay:(NSTimeInterval)delay
Parameters
- showCloseButton
Set to
YES
to display the close button after rendering ads.
- delay
The time to delay showing the close button after rendering the ad. A value of 0 will show the button immediately.
Discussion
Shows a close button after the specified delay after the ad is rendered.
This can be used for both inline/banner/custom and interstitial ads. For most cases this should not be required since banner ads don’t usually have a need for a close button and richmedia ads that expand or resize will offer their own close button.
This SHOULD be used for interstitial ads that are known to not be richmedia as they will not have a built in close button.
The setting applies for all subsequent updates. The button can be customized using the MASTAdViewCustomCloseButton: delegate method.
Warning: Ensure [MASTAdView reset] is invoked when the instance will no longer be used or is being removed from the view stack. This will prevent the main NSRunLoop from retaining the MASTAdView instance after its intended release.
See Also
Declared In
MASTAdView.h
showInterstitial
Shows and closes the interstitial view.
- (void)showInterstitial
Discussion
Shows and closes the interstitial view.
Can only be used if the instance was initialized with initInterstitial.
Declared In
MASTAdView.h
showInterstitialWithDuration:
Shows the interstitial and automatically closes after the specified duration.
- (void)showInterstitialWithDuration:(NSTimeInterval)duration
Parameters
- duration
The amount of time to display the interstitial before closing it.
Discussion
Shows the interstitial and automatically closes after the specified duration.
Can only be used if the instance was initialized with initInterstitial.
Declared In
MASTAdView.h
update
Issues an immediate ad update and cancles any existing ad update.
- (void)update
Discussion
Issues an immediate ad update and cancles any existing ad update.
If [MASTAdViewDelegate MASTAdViewSupportsCalendar:] is implemented by the delegate then this message will determine if a request to the user for access to the calendar is needed. If so, the instance will request access from the user. Developers desiring to control when this request occurs can do so prior to calling update. Refer to iOS EKEventStore documentation for more information.
Declared In
MASTAdView.h
updateWithTimeInterval:
Issues an immediate ad update and cancels any pending ad update. Will automatically update every interval seconds.
- (void)updateWithTimeInterval:(NSTimeInterval)interval
Parameters
- interval
The delay between requesting updates after the initial update.
Discussion
Issues an immediate ad update and cancels any pending ad update. Will automatically update every interval seconds.
If [MASTAdViewDelegate MASTAdViewSupportsCalendar:] is implemented by the delegate then this message will determine if a request to the user for access to the calendar is needed. If so, the instance will request access from the user. Developers desiring to control when this request occurs can do so prior to calling update. Refer to iOS EKEventStore documentation for more information.
Warning: Ensure [MASTAdView reset] is invoked when the instance will no longer be used or is being removed from the view stack. This will prevent the main NSRunLoop from retaining the MASTAdView instance after its intended release.
See Also
Declared In
MASTAdView.h