Hybrid app integration
A hybrid app uses both native URL requests and in-app WebViews to communicate with your servers. HUMAN must treat those as one visitor, where the native SDK VID and the WebView VID must be the same. Your app is a hybrid app if both of the following are true:
- It loads your website (or a HUMAN-protected page on it) in an in-app WebView, AND
- That site is protected by HUMAN Bot Defender or Account Defender
The app doesn’t necessarily need to be called “hybrid” to be considered a hybrid app. These topologies all count:
- Login, signup, account, billing, or help pages shown in a WebView
- OAuth or SSO pages on a login subdomain of the same registrable root (for example
login.example.comwhen the root isexample.com) - A Cordova (or similar) app whose UI is a whole-app WebView of a protected site
- Cross-platform WebViews such as
react-native-webview, Expo WebView, Flutterwebview_flutter, or Ionic or Capacitor
A WebView that only loads an unprotected static page (for example, a privacy policy that is not behind HUMAN) does not need hybrid configuration. However, if that same WebView later loads a protected login or account flow, treat it as hybrid.
You can learn how to integrate hybrid apps with the HUMAN Mobile SDK with this guide.
Prerequisites
- A supported WebView:
WKWebView- Android
WebViewwithsetupWebView, or iOSautomaticSetup - For wrapper-hosted WebViews, see our WebView container support matrix
- A native app integration:
SFSafariViewController and Chrome Custom Tabs own a cookie jar the app cannot write with the default Hybrid App path, so they need a unique integration. See Maintain VIDs for external browsers for details.
Integrate with a hybrid app
Domain configuration
Set hybridAppPolicy.webRootDomains to the bare registrable root of the site in the WebView.
Canonical form: example.com
- No leading dot is preferred and should be used whenever possible. However, a leading dot is accepted and equivalent, which means
.example.comis stored and matched the same asexample.com. If your older samples use.example.com, there’s no need to correct them. - No scheme (
https://) - No
www - No path or port
This value is used to decide which WebView hosts get hybrid support and as the Domain when the SDK sets _pxmd and _pxwvm. webRootDomains = ["example.com"] is sufficient for the apex and every sub-domain of that root.
How matching works
A WebView host matches a configured domain when the host equals that value, or when the host ends with a dot plus that value. That is not a free-text suffix test: notexample.com does not match example.com.
For more domain configuration scenarios, open the options below.
Multiple Application IDs
If the WebView loads a different registrable domain (not a sub-domain of the first root), list that root under the App ID that protects it.
OAuth on login.example.com does not need a second entry if example.com is already configured.
Remote domain configuration
HUMAN can push hybrid root domains for your App ID from the Portal. The SDK unions those domains with the list in policy. A domain correction does not require an app release.
Still set webRootDomains in the app when you can. Contact HUMAN if you need a server-side domain update.
Cookie Domain versus test harnesses
Cookie Domain versus test harnesses
A real Set-Cookie: Domain=example.com header is not host-only: it is readable on the apex and on sub-domains.
Some test-harness APIs that take a bare domain string — for example Playwright addCookies({ domain: 'example.com' }) — can create a host-only cookie instead. That can make a lab test pass (or fail) in a way production never would. Treat the HTTP Set-Cookie header as the source of truth, not the harness helper.
Common misconfiguration
Listing a sub-domain (www.example.com, api.example.com, login.example.com) instead of the registrable root is the most common failure.
It fails silently. Instrumentation still matches that host, so the integration looks healthy, but cookies are scoped to the sub-domain. Other hosts on the same site never share VID with native. Configured sub-domains are kept as-is; they are not reduced to the root.
Do not copy the dotted cookie name from browser DevTools into webRootDomains as a requirement. DevTools often shows .example.com; configure example.com.
Enable external WebViews support
This support has been available since v4.0.1.
If WebViews are created outside native code but still use WKWebView or Android WebView (for example react-native-webview), enable supportExternalWebViews.
The HUMAN React Native wrapper and Expo module already set supportExternalWebViews = true. Flutter, Ionic, Capacitor, and Cordova do not. Instead, set the flag in native start together with webRootDomains. See WebView container support for more information.
Android
iOS
Disable JavaScript evaluation for Apple Pay on the Web
If your website uses Apple Pay on the Web, disable JavaScript evaluation by the SDK. Apple Pay can’t be used alongside script injection APIs on iOS 13-15.
If your app only targets iOS 16 or above, you don’t need to disable JavaScript evaluation, and you can skip this step.
Enable Hybrid App support
Pass the WebView instance to the SDK:
- iOS:
HumanSecurity.setupWebView(webView:navigationDelegate:) - Android:
HumanSecurity.setupWebView(webView:webViewClient:)
Important: Do not set the navigationDelegate (iOS) or webViewClient (Android) after setupWebView.
On iOS, set HSHybridAppPolicy.automaticSetup to true to detect and set up WKWebView instances without calling setupWebView for each one.
Below are example implementations for both Android and iOS:
Android
iOS
In particular, note the following:
- Web root domains: Set the registrable root (
example.com) inwebRootDomains. Do not usewww.example.comorhttps://…. - Start the SDK as early as possible on the main thread so URL requests include HUMAN headers.
- Set up WebViews:
- Android:
HumanSecurity.setupWebView(webView:webViewClient:). Do not set theWebViewClientdirectly after this. - iOS:
HumanSecurity.setupWebView(webView:navigationDelegate:). Do not set thenavigationDelegatedirectly after this.
- Android:
Notes:
- iOS automatic setup:
HSHybridAppPolicy.automaticSetup = truesets upWKWebViewinstances without callingsetupWebViewfor each one. - Multiple App IDs: Use
HumanSecurity.start(appIds:policy:)and pass the App ID that owns each root, as in the example above.
Confirm the integration is working
The native VID and the WebView VID must be identical.
Confirm the following:
If your sync is successful, you should see the following cookies in an instrumented WebView:
If those VIDs differ after the first navigation, refer to Troubleshooting.
Verification
Run the Doctor App Web view test before production. Treat a passing hybrid/WebView test as a release gate.
-
Enable the Doctor App (
HSDoctorAppPolicy.enabled = true). See our verification guide for more information. -
Choose the Web view framework test and exercise the WebView that loads your protected site.
-
On the summary screen, confirm the test passed.
-
Export the result JSON and keep it. That export is the standard attachment for HUMAN Support.
-
Ensure you disable the Doctor App (
enabled = false) before you ship.
Preserve cookies & storage on logouts
If the app clears cookies or WebView storage on logout, use Mobile SDK 5.3.0 or later. That release restores missing _pxmd / _pxwvm after a wipe (cookies channel; other channels restore _pxwvm as appropriate). Older SDKs stay broken until the next full handshake.
Prevention still matters, especially on Android native and wrapper-hosted WebViews where hybrid often depends on cookies. If you write deletion logic, skip HUMAN keys. Do not delete every cookie in the WebView store.
See Use of cookies and web storage for full descriptions.
Cookies (skip these)
Local storage (skip these)
Session storage (skip these)
Maintain VIDs for external browsers
When embedding web content using SFSafariViewController on iOS or Chrome Custom Tabs on Android, those components run in a separate process and use an isolated cookie jar that the SDK cannot access directly. To maintain Visitor ID (VID) alignment between your native app and the web sessions inside these external browsers, you must explicitly pass the SDK’s VID in the URL query parameters.
The SDK retrieves its Visitor ID asynchronously from the HUMAN Collector during the startup flow (HumanSecurity.start()).
This means the VID getter may return nil (or null) if you attempt to launch the external browser immediately on application launch, before the SDK has completed its initial handshake.
If your application flow requires opening the browser immediately upon app launch and the VID is not ready in time, contact HUMAN Support for a custom solution.
- Initialize and run the HUMAN Mobile SDK.
- Contact HUMAN Support or your Technical Account Manager (TAM) to enable the “Extract VID from URL” configuration for your Application ID on the backend. Without this server-side configuration, the embedded web sensor ignores the URL parameter.
- Pass the VID following the examples below.
Android
iOS
To pass the VID on Android, append it as the _pxvid query parameter to your Uri before launching the Custom Tab.
Leave _pxhd to the SDK
_pxhd is an HTTP cookie that carries an encrypted VID and socket IP. On Enforcer traffic, it is consulted before _pxvid.
Inside an instrumented WebView, the SDK and Sensor manage _pxhd so the SDK’s VID wins. You may see _pxhd disappear in that WebView; that is expected.
If native and WebView VIDs diverge on a domain that is also a desktop property, _pxhd is the first thing support checks. This can’t be fixed by changing webRootDomains alone, so in this case, contact HUMAN Support.
Troubleshooting
Native VID and WebView VID differ
First check: webRootDomains is the bare root (example.com), not a sub-domain. Confirm matching with the table above.
Then check the following:
- The WebView is a supported container
setupWebView/automaticSetup/supportExternalWebViewsmatches how the WebView is created- Contact HUMAN if
_pxhdis on a domain shared with desktop.
Challenge loop inside a WebView
Check the VID split (native vs. _pxvid). A challenge loop usually means two identities. Confirm the container is supported. SFSafariViewController and Chrome Custom Tabs require external browser integration.