Does Web SDK support native platforms?(Legacy)

The SDK supports integrations with Native platforms such as iOS and Android. This is done with the help of a Web View.

Android

To ensure that the SDK loads up inside an Android WebView. Make sure the following permissions are present in the Manifest

<uses-permission android:name="android.permission.INTERNET"/>

The following settings on the WebView are also necessary to ensure the SDK has the necessary permissions.

webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setLoadsImagesAutomatically(true);
webSettings.setAppCacheEnabled(true);

The lifecycle of a WebPage in WebView is coupled to the Android app lifecycle. Therefore for proper user experience, we need to notify Haptik SDK when the app goes in the background. Below is the code snippet to do so.

override fun onStop() {
    super.onStop()
    webview.loadUrl("javascript:window.HaptikSDK.pause();")
}

Note

If we use Web SDK deployment for the Haptik bot on Android app, then we would require an additional configuration for the upload file buttons to work.

As the Web SDK has been integrated into the Webview, it cannot directly open up the file system to allow the user to select a file to upload.

We would need to implement a callback on the Webview which can open up the file system.

You can refer here for the link to the documentation to help you with this process

iOS

iOS doesn't need any extra permissions in order to operate. Just open the HTML file where you've configured the SDK inside the app.

Just like Android, in iOS as well the lifecycle of a WebPage is coupled to the iOS app lifecycle. We need to notify Haptik SDK when the app goes in the background. To do this, please add an inactive state observer in your view controller which consists of the WkWebView, and add the following code:

override func viewDidLoad() {
super.viewDidLoad()
// Register background notification
NotificationCenter.default.addObserver(
forName: UIApplication.willResignActiveNotification,
object: nil,
queue: nil,
using: { note in
// App moved to background!
self.webView?.evaluateJavaScript("window.HaptikSDK.pause();", completionHandler: nil)
})
}
deinit {
// Remove Notification observer
NotificationCenter.default.removeObserver(self, name: UIApplication.willResignActiveNotification, object: nil)
}

Clevertap is not supported for Web SDK & Android SDK. 

If you are not using the Haptik SDK with CleverTap Multi-instance SDK and if you're already using CleverTap SDK in your app and sending analytic events then there might be a potential issue where CleverTap can't support two different accounts' events getting fired from one app.

In this case, don't enable CleverTap functionality for Haptik SDK.

Can’t find what you’re looking for? Email us at support@haptik.ai.