Skip to main content
This article describes how to use the MoEngage Web SDK in WebView inside a Mobile App.
  • WebSDK uses browser storage (LocalStorage and IndexedDB) to queue and persist events. This storage is not enabled by default in a WebView, unlike a regular browser tab.
  • If storage is not explicitly enabled on both Android and iOS, the SDK fails to queue events. This failure is silent — there is no user-facing error — but appears in your app’s error monitoring (for example, Bugsnag or Sentry) as No available storage method found, sometimes followed by MOE_QUEUE_TIMEOUT: exceeded 10000ms.
  • For Mobile Apps, you must explicitly enable JavaScript and browser storage — both are required, not just JavaScript.

Steps to Enable WebSDK in WebView

To run WebSDK in WebView,
  • Ensure you have correctly integrated Web SDK into your website.
  • Ensure you provide permission to use JavaScript for your Android/iOS app.
  • Ensure browser storage (LocalStorage/IndexedDB) is enabled and persistent for the WebView — see the storage steps below for each platform.

For Android Apps

Step 1: Configure Your WebView Within your app, locate the WebView component for which you wish to enable JavaScript. Ensure you have the proper imports:
Step 2: Enable JavaScript and DomStorage Permissions Using the WebSettings class, enable JavaScript and DOM storage:
setDomStorageEnabled(true) covers LocalStorage/SessionStorage. IndexedDB is generally available by default on modern Chromium-based WebView once DOM storage is enabled, but some custom WebView builds or privacy-hardened configurations may restrict it independently. If you continue to see storage errors after enabling DOM storage, verify IndexedDB availability directly inside the WebView session using chrome://inspect.
Step 3: Advanced Settings For more control, you may use additional settings such as:
Validate the URL you load in WebView before enabling JavaScript navigation, to avoid executing untrusted scripts.

For iOS Apps

Step 1: Import WebKit First, ensure you’ve imported the WebKit framework in your ViewController:
Step 2: Create a WKWebView with Persistent Storage Create an instance of WKWebView, and make sure its WKWebViewConfiguration uses a persistent website data store rather than a non-persistent/ephemeral one. A non-persistent data store blocks the storage APIs (LocalStorage/IndexedDB) the SDK depends on to queue events, and discards any SDK data once the WebView is deallocated.
Step 3: Enable JavaScript JavaScript is enabled by default on WKWebView. To verify or change the setting, use WKWebpagePreferences.allowsContentJavaScript on iOS 14 and later, and fall back to WKPreferences.javaScriptEnabled for earlier versions:

Verifying Storage Is Working

Before raising a support ticket for missing or delayed events in a WebView session, confirm the following inside the actual WebView (not a regular browser tab — WebView storage behavior can differ even on the same device):
  • Android: setDomStorageEnabled(true) is set on the specific WebView instance loading the site.
  • iOS: the WKWebView is configured with WKWebsiteDataStore.default(), not a non-persistent store.
  • IndexedDB is accessible inside the WebView session — check via remote inspector (chrome://inspect for Android, Safari Web Inspector for iOS) that window.indexedDB is defined and usable.

Supported Modules

In WebView, we support the following modules:
  • Data Tracking
  • On-site Messaging
  • Cards
  • Web Personalization