基于 WebView 的移动应用桥接集成
许多移动应用都是基于 WebView 构建的。FlareLane 充分考虑了这一点,为基于 WebView 的应用提供了多种便捷功能和桥接代码。
基于 WebView 的移动应用存在的问题
Section titled “基于 WebView 的移动应用存在的问题”在基于 WebView 的移动应用中,移动应用与网站运行在彼此独立的环境里,因此应用无法感知网页上发生的操作。
为解决这一问题,您需要桥接代码,把 WebView 内部发生的操作同步传递给应用。FlareLane 是唯一一家自行构建并提供该桥接代码的解决方案。
桥接集成步骤
Section titled “桥接集成步骤”1. 接入 Web SDK
Section titled “1. 接入 Web SDK”由于网站是用户操作发生的主要平台,因此请将 FlareLane Web SDK 接入到当前显示在 WebView 中的网站。
2. 在 Mobile SDK 中添加桥接代码
Section titled “2. 在 Mobile SDK 中添加桥接代码”将 FlareLane 提供的、对应各平台的桥接类添加到您的 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. 通过 Web SDK 集成客户数据
Section titled “3. 通过 Web SDK 集成客户数据”接入完成后,在 WebView 内通过 Web SDK 调用的以下函数,将通过桥接同时触发应用中对应的 Mobile SDK 函数。
- setUserId
- trackEvent
- setTags