Mobile SDK iOS: EPZPromoWebViewControllerDelegate

From ePrize Developers Wiki

(Difference between revisions)
Jump to: navigation, search
(Initial authoring)
Current revision (15:29, 7 November 2014) (edit) (undo)
m (Minor formatting updates)
 
Line 30: Line 30:
-
 
+
<hr/>
=== promoWebViewCreated: ===
=== promoWebViewCreated: ===
Line 49: Line 49:
-
 
+
<hr/>
=== promoWebView:didFireEvent:withData: ===
=== promoWebView:didFireEvent:withData: ===

Current revision

Contents

Overview

The EPZPromoWebViewControllerDelegate protocol defines methods that a delegate of EPZPromoWebViewController can implement to handle actions pertaining to interactions with the class methods.


Tasks

- closePromoWebView: required method
- promoWebViewCreated: optional method
- promoWebView:didFireEvent:withData: optional method


Instance Methods

closePromoWebView:

Dispatched when the view’s "Close" button is pressed.

- (void) closePromoWebView:(EPZPromoWebViewController *)controller

Parameters

controller
The instance of EPZPromoWebViewController that dispatched the method.

Discussion
The delegate responds to a user clicking on the view’s "Close" button, alerting the delegate to take actions to remove the view from the hierarchy.

Declared In
EPZPromoWebViewControllerDelegate.h



promoWebViewCreated:

Dispatched when the EPZPromoWebViewController view is fully created.

- (void) promoWebViewCreated:(EPZPromoWebViewController *)controller

Parameters

controller
The instance of EPZPromoWebViewController that dispatched the method.

Discussion
The delegate responds to the EPZPromoWebViewController view being successfully and fully created. This method is a convenience method you can use if you desire to know when the view was created, to handle other actions in other parts of your application.

Declared In
EPZPromoWebViewControllerDelegate.h



promoWebView:didFireEvent:withData:

Dispatched when the EPZPromoWebViewController receives an event from the web page loaded into its web view.

- (void) promoWebView:(EPZPromoWebViewController *)controller didFireEvent:(NSString *)eventName withData:(NSDictionary *)data

Parameters

controller
The instance of EPZPromoWebViewController that dispatched the method.
eventName
The event name triggered. Presently there are no set values for this parameter.
data
A dictionary object with additional event data, if any. Presently there are no set values for dictionary key/value pairs, as they originate from the web page, not the SDK's web view.

Discussion
The delegate responds to an event being triggered from the SDK's web view, which catches it from a web page it contains. This method can be used to respond to events and have the parent app act accordingly (e.g. store user information passed in an event, etc.).

Important Note: Since there are no standard set of events, nor are there standard event data key/value pairs, it is ultimately the responsibility of your application to handle the event and react accordingly, including any necessary logic to check for event names and data key/value pairs, as seen in the code example below.

Event Handling Example
If your company plans to run promotions in which you would like to pass a user email address from the web page into the app, you would have the promotion web page call the trackEvent(eventName, data) function on the MobileSDK JavaScript Object, like so:

// JavaScript
MobileSDK.trackEvent('saveUserEmail', {"email": document.getElementById("email").value});

Then in your mobile application, you would include logic to search the event data for an "email" key/value pair, and store it as needed.

- (void) promoWebView:(EPZPromoWebViewController *)controller didFireEvent:(NSString *)eventName withData:(NSDictionary *)data
{
    [data objectForKey:@"email"]
    if ([eventName isEqualToString:@"saveUserEmail"] && userEmail != nil) {
        // Store user email as needed
    }
}

Declared In
EPZPromoWebViewControllerDelegate.h

Personal tools