Bridge Integration for WebView-Based Mobile Apps
Many mobile apps are built on top of a WebView. FlareLane accounts for this by providing a variety of convenience features and bridge code for WebView-based apps.
The Problem with WebView-Based Mobile Apps
Section titled “The Problem with WebView-Based Mobile Apps”In a WebView-based mobile app, the mobile app and the website run in separate environments, so the app has no way of knowing about actions that happen on the web.
To solve this, you need bridge code that propagates actions taken inside the WebView to the app as well. FlareLane is the only solution that builds and provides this bridge code itself.
Bridge Integration Steps
Section titled “Bridge Integration Steps”1. Integrate the Web SDK
Section titled “1. Integrate the Web SDK”Since the website is the primary platform where user actions occur, integrate the FlareLane Web SDK into the website currently displayed in the WebView.
2. Add the Bridge Code to the Mobile SDK
Section titled “2. Add the Bridge Code to the Mobile SDK”Add the platform-specific bridge class provided by FlareLane to your WebView.
Android
Section titled “Android”webview.addJavascriptInterface( FlareLaneJavascriptInterface(context), FlareLaneJavascriptInterface.BRIDGE_NAME)webview.addJavascriptInterface( new FlareLaneJavascriptInterface(context), FlareLaneJavascriptInterface.BRIDGE_NAME);webView.configuration.userContentController.add( FlareLaneJavascriptInterface(), name: FlareLaneJavascriptInterface.BRIDGE_NAME)FlareLaneJavascriptInterface *interface = [[FlareLaneJavascriptInterface alloc] init];[webView.configuration.userContentController addScriptMessageHandler:interface name:FlareLaneJavascriptInterface.BRIDGE_NAME];3. Integrate Customer Data via the Web SDK
Section titled “3. Integrate Customer Data via the Web SDK”Once the integration is complete, the following functions called via the Web SDK inside the WebView will, through the bridge, also invoke the corresponding Mobile SDK functions in the app.
- setUserId
- trackEvent
- setTags