ORACoreWebViewDelegate Class Reference
Inherits from | NSObject |
---|---|
Conforms to | UIWebViewDelegate WKNavigationDelegate |
Declared in | ORACoreWebViewDelegate.h |
Overview
UIWebView
Generating events through the JavaScript tag UIWebViews embedded in a native app can generate events by using JavaScript helper methods that interact with the native app to generate and send events, or by using the JavaScript tag in the embedded web content to generate and send events. Follow these instructions to use the JavaScript tag. *
The native app must implement the Mobile Library for iOS, the web content must be tagged with the JavaScript tag, and you must be familiar with iOS UIWebViews. *
If we don't need to do any web view delegation of our own, we'll simply create a retained instance of ORAWebViewDelegate and let it do the work for us
There are two methods of alerting the Data Collector of JavaScript-triggered events. The first is using the supplied ORAWebViewDelegate, shown here:
Method 1 – supplied delegate
(void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:@"https://bank.wt-go.com/invest"];
// If we want to share a session between the app and the website,
// we'll append it to the URL before triggering the request
// using the appendSessionParamsToUrl: method below
NSURL *sessionedUrl = [[ORADataCollector sharedCollector] appendSessionParamsToUrl:url];
// Set our retained ORAWebViewDelegate as the UIWebView's delegate
self.webView.delegate = self.wtDelegate;
[self.webView loadRequest:[NSURLRequest requestWithURL:sessionedUrl]];
}
If we need our own web view delegation methods, we'd mark our self as the delegate as follows.
Method 2 – Self-supplied delegate
(void)viewDidLoad { [super viewDidLoad];
NSURL *url = [NSURL URLWithString:@"https://bank.wt-go.com/invest"];
// If we want to share a session between the app and the website,
// we'll append it to the URL before triggering the request
// using the appendSessionParamsToUrl: method below
NSURL *sessionedUrl = [[ORADataCollector sharedCollector] appendSessionParamsToUrl:url];
// If we do this, we must implement webView:ShouldStartLoadWithRequest:navigationType self.webView.delegate = self;
[self.webView loadRequest:[NSURLRequest requestWithURL:sessionedUrl]];
}
(BOOL)webView:(UIWebView )webView shouldStartLoadWithRequest:(NSURLRequest )request navigationType:(UIWebViewNavigationType)navigationType
{
if (![ORAWebViewDelegate shouldStartLoadWithRequest:request])
{
return NO;
}
//Any custom logic here
return YES;
}
WKWebview
{
BOOL shouldStart = [ORAWebViewDelegate shouldStartLoadWithRequest:navigationAction.request];
if (!shouldStart)
{
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
// Any custom decision policy code
}