SWRLContentManager Class Reference
Inherits from | SWRLManager : NSObject |
---|---|
Conforms to | SWRLVisitManagerDelegate |
Declared in | SWRLContentManager.h SWRLContentManager.m |
Overview
A SWRLContentManager component if loaded, will consume Visit events using the SWRLVisitManagerDelegate protocol and use those events to trigger content requests through the API. If content is returned, then depending upon the application state and settings, it is responsible for displaying local notifications (if the application is in the background) and launching a content view (full screen interstitial view controller) or opening an application deep link or exterunal URL.
This component is not loaded by default, so it must be loaded explicitly at startup or whenever content experiences are needed.
If you need to be informed of content delivery event, then you can subscribe to the delegate interfaces which provide callbacks when various types of content is delivered. However, since the multi-cast delegate system is a one way broadcast of information, if you need to customize the details of the flow, block certain creatives from launching at runtime, you will need to subclass this component and override various methods to alter its default behavior.
Accessing Attributes
recent
The most recent visit object. This is either the current visit or a recently exited one.
@property (nonatomic, readonly) SWRLVisit *recent
Declared In
SWRLContentManager.h
lastContent
The last piece of content received
@property (nonatomic, readonly) SWRLContent *lastContent
Declared In
SWRLContentManager.h
Customizing the Content View
contentViewPresenter
The UIViewController from which to present the SWRLContentViewController. Override this property to change which controller is used. By default, the implementation searches for the top most UIViewController and returns that.
@property (nonatomic, readonly) UIViewController *contentViewPresenter
Declared In
SWRLContentManager.h
contentViewController
The UIViewController which is the default presentation view for content. You can override viewControllerForContent to change the default.
@property (nonatomic, readonly) SWRLContentViewController *contentViewController
Declared In
SWRLContentManager.h
contentToastView
The UIView which represents the current toast view (if displayed).
@property (nonatomic, readonly) UIView *contentToastView
Declared In
SWRLContentManager.h
Receiving Content Events
– didReceiveContentURL:
Called when content of type URL is received.
- (void)didReceiveContentURL:(SWRLContent *)content
Parameters
content |
The content that was just received. |
---|
Discussion
The default implementation just forwards the event via the delegate interface.
Declared In
SWRLContentManager.h
– didReceiveContentSwirl:
Called when content of type Swirl is received.
- (void)didReceiveContentSwirl:(SWRLContent *)content
Parameters
content |
The content that was just received. |
---|
Discussion
The default implementation just forwards the event via the delegate interface.
Declared In
SWRLContentManager.h
– didReceiveContentCustom:
Called when content of type Custom is received.
- (void)didReceiveContentCustom:(SWRLContent *)content
Parameters
content |
The content that was just received. |
---|
Discussion
The default implementation just forwards the event via the delegate interface.
Declared In
SWRLContentManager.h
– didReceiveContent:
Called when content of any type is received.
- (void)didReceiveContent:(SWRLContent *)content
Parameters
content |
The content that was just received. |
---|
Discussion
This is the first method called when content is received. Note that content can be received
from the platform or it can be received as part of processing a notificaton. The default implementation of this method sets lastContent
and its timestamp, switches on content type to call the type specific variants of didReceiveContent...
and
starts the display process for either a background notification or foreground content experience.
Warning: This method is critical to the proper operation of the SWRLContentManager. If you override this
method, you must pass this message to super
.
Declared In
SWRLContentManager.h
Controlling Content Display
– shouldShowToastFirst:
Called before content is shown in foreground.
- (BOOL)shouldShowToastFirst:(SWRLContent *)content
Parameters
content |
The content that is about to be opened. |
---|
Return Value
YES if you want to display only the toast view and not the full interstitial
Discussion
The default implementation returns the value of the SWRLSettingContentShowToastFirst setting which defaults to NO.
Declared In
SWRLContentManager.h
– shouldShowURLContent:
Called before a deep-link or external URL is activated.
- (BOOL)shouldShowURLContent:(SWRLContent *)content
Parameters
content |
The content that is about to be opened. |
---|
Return Value
YES if you want to display the content, NO if you do not.
Discussion
If you need to control the display of certain content items, you can override this method and inspect the content parameter and either return YES to continue the action or NO to suppress it. The default implementation always returns YES.
Declared In
SWRLContentManager.h
– shouldShowContentView:
Called before a web interstitial is about to be displayed.
- (BOOL)shouldShowContentView:(SWRLContent *)content
Parameters
content |
The content that is about to be displayed. |
---|
Return Value
YES if you want to display the content, NO if you do not.
Discussion
If you need to control the display of certain content items, you can override this method and inspect the content parameter and either return YES to continue the action or NO to suppress it. The default implementation always returns YES.
Declared In
SWRLContentManager.h
– shouldShowNotification:content:
Called before a local notification is generated.
- (BOOL)shouldShowNotification:(id)note content:(SWRLContent *)content
Parameters
note |
The UILocalNotification that is about to be display. It can be altered or modified at this point. |
---|---|
content |
The content from which the notification has been generated. |
Return Value
YES if you want to display the notification, NO if you do not.
Discussion
If you need to control the display of certain notifications, you can override this method and inspect the content parameter and either return YES to continue the action or NO to suppress it. The default implementation always returns YES.
Declared In
SWRLContentManager.h
– shouldShowNotificationForContent:completion:
Called before a local notification is generated. (async)
- (void)shouldShowNotificationForContent:(SWRLContent *)content completion:(void ( ^ ) ( SWRLContent *, BOOL ))completion
Parameters
content |
The content from which the notification has been generated. |
---|---|
completion |
The completion to call when ready to display or reject |
Discussion
If you need to control the display of certain notifications, you can override this method and inspect the content parameter and either return YES to continue the action or NO to suppress it. The default implementation of this method calls the synchronous version above.
Declared In
SWRLContentManager.h
– didShowContentViewController:
Called after the SWRLContentViewController has been shown. The default implementation of this method, simply forwards the message to the delegate bus as contentManager:didShowContentViewController.
- (void)didShowContentViewController:(SWRLContentViewController *)controller
Parameters
controller |
---|
Declared In
SWRLContentManager.h
– didDismissContentViewController:
Called after the SWRLContentViewController has been dismissed. The default implementation of this method: [self.delegate contentManager:self didDismissContentViewController:controller; [self showToastView:[self toastViewForContent:controller.content]];
- (void)didDismissContentViewController:(SWRLContentViewController *)controller
Parameters
controller |
---|
Declared In
SWRLContentManager.h
– toastViewForContent:
Called to create the toastView. The default implementation creates a SWRLToastView with a title and message attributes derived from the notification associated with this content. If you just want to modify attributes of the standard toastView, call the super (default) implementation, make the changes and return that view. If you do not want to show a toastView, return nil.
- (UIView *)toastViewForContent:(SWRLContent *)content
Parameters
content |
The content for which to provide a toast. |
---|
Return Value
the view you want to use as the toast, or nil if no toast is desired.
Declared In
SWRLContentManager.h
– showToastView:
Called to show the toastView.
- (void)showToastView:(UIView *)view
Parameters
view |
the view to use as the toast view, should do nothing it nil is passed |
---|
Discussion
The default implementation, calls size to fit on the toastView and then attempts to align the toast right under the top view controller’s navigation bar.
Declared In
SWRLContentManager.h
– showContentURL:
Called to activate a deep or external link.
- (void)showContentURL:(SWRLContent *)content
Parameters
content |
The content containing the link to open. |
---|
Discussion
The default implementation of this method first calls the shouldShowURLContent
and depending upon
its return value, either logs an event that the show was suppressed, or calls openURL.
Declared In
SWRLContentManager.h
– showContentViewController:wait:
Called to present interstitial content.
- (void)showContentViewController:(SWRLContent *)content wait:(BOOL)wait
Parameters
content |
The content containing the URL to display. |
---|---|
wait |
Show the window immediately or wait for load first |
Discussion
The default implementation of this method creates the SWRLContentViewController if it does not exist
and begins asynchronously loading that content. When the content load completes, it calls the
shouldShowContentView
method to see if the content should be display and logs an event if the display is
suppressed, otherwise it presents the SWRLContentViewController from the result of calling contentViewPresenter.
Warning: It is not recommended that you override this method. If for some reason you need to, you should make sure to
call the implementation in super
.
Declared In
SWRLContentManager.h
– showContentToastView:
Call this method to force display of the SWRLContentToastView
- (void)showContentToastView:(SWRLContent *)content
Parameters
content |
content object from which the toast will be derived |
---|
Discussion
This forces the display of the toast view for the content supplied
Declared In
SWRLContentManager.h
– showContentViewController
Call this method to force display of the SWRLContentViewController.
- (void)showContentViewController
Discussion
You would call this method if you wanted to implement a return to content button or other interface widget that
allows your users to dismiss and relaunch the content view.
In order to facilitate access to the SWRLContentManager from other parts of the program, you can call [SWRLContentManager shared]
to access the last content manager created (usually there is only one).
Declared In
SWRLContentManager.h
– dismissContentViewController:
Call this method to clear the content view.
- (void)dismissContentViewController:(BOOL)animated
Parameters
animated |
Use animation when removing the view |
---|
Discussion
It will clear the view if it is currently presented otherwise it will do nothing.
Declared In
SWRLContentManager.h
– requestContentPreview:completion:
Call this method to request content with a demo-code
- (void)requestContentPreview:(NSString *)previewCode completion:(void ( ^ ) ( NSError *))completion
Parameters
previewCode |
A preview code retrieved from the platform for a given creative. |
---|---|
completion |
Called when the content has been shown or there was an error |
Discussion
Makes a request for content with a given preview code and if successful, begins the normal receive content flow which results in an interstitial view. The completion is called in either case and an error is passed or nil when successful.
Declared In
SWRLContentManager.h
Other Methods
– viewControllerForContent
- Override this to return a subclass of SWRLContentViewController with your own customizations. @ @return The view you want to use for the contentViewController. MUST be a subclass of SWRLContentViewController.
- (SWRLContentViewController *)viewControllerForContent
Declared In
SWRLContentManager.h
– openURL:completion:
Override this to handle any URLs that are opened either from a URL content or a URL widget from any interstitial content.
- (void)openURL:(NSURL *)url completion:(void ( ^ ) ( BOOL ))completion
Parameters
url |
the url to open |
---|---|
completion |
the completion to call (with success/failure flag) |
Declared In
SWRLContentManager.h
+ shared
Call this to access the last content manager created. This method is provided as a convenience to save the programmer from having to keep a reference to the content manager or subclass it added when Swirl was started.
+ (SWRLContentManager *)shared
Declared In
SWRLContentManager.h
Other Methods
– visitManager:didBeginVisit:
Called when a Visit to a new Location and Placement is beginnng
- (void)visitManager:(SWRLVisitManager *)manager didBeginVisit:(SWRLVisit *)visit
Parameters
manager |
VisitManager |
---|---|
visit |
Visit object which contains information on start, end and accumulated and elapsed dwell time |
Declared In
SWRLVisitManager.h
– visitManager:didUpdateDwellForVisit:
Called periodically as a user remains in a current Location and Placement
- (void)visitManager:(SWRLVisitManager *)manager didUpdateDwellForVisit:(SWRLVisit *)visit
Parameters
manager |
VisitManager |
---|---|
visit |
Visit object which contains information on start, end and accumulated and elapsed dwell time |
Declared In
SWRLVisitManager.h
– visitManager:didEndVisit:
Called when a Visit to a new Location and Placement has ended
- (void)visitManager:(SWRLVisitManager *)manager didEndVisit:(SWRLVisit *)visit
Parameters
manager |
VisitManager |
---|---|
visit |
Visit object which contains information on start, end and accumulated and elapsed dwell time |
Declared In
SWRLVisitManager.h