- Print
- DarkLight
- PDF
Analytics - Embedded Browser Events Guide
Article summary
Did you find this summary helpful?
Thank you for your feedback
Analytics - Embedded Browser Events Guide Document
The Webtrends SDK provides a method of sharing session information between a parent application, and an embedded UIWebView. After following the steps outlined in Implementation, any app implementing the iOS SDK will be able to see and log events generated by the Webtrends JavaScript tag.
Requirements
The native app must implement the Webtrends Mobile Library for iOS, the web content must be tagged with the Webtrends JavaScript tag, and you must be familiar with iOS UIWebViews.
Implementation
Using WKWebview
When using WKWebview, conform to WKNavigationDelegate, and implement -webView:decidePolicyForNavigationAction:decisionHandler: Include the following inside your method:
Swift
func webView(webView: WKWebView, decidePolicyForNavigationAction navigationAction:
WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> Void) {
let shouldStart = WTWebViewDelegate.shouldStartLoadWithRequest(navigationAction.request)
if !shouldStart {
decisionHandler(.Cancel)
return
}
// Any custom decision policy code. Make sure your code calls decisionHandler with your chosen action policy.
}
Objective-C
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
BOOL shouldStart = [WTWebViewDelegate shouldStartLoadWithRequest:navigationAction.request];
if (!shouldStart)
{
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
// Any custom decision policy code. Make sure your code calls decisionHandler with your chosen action policy.
}
Was this article helpful?