Skip to content

Add Android and iOS WebView detection with Client Hints support#614

Draft
Copilot wants to merge 4 commits intomasterfrom
copilot/add-webview-detection
Draft

Add Android and iOS WebView detection with Client Hints support#614
Copilot wants to merge 4 commits intomasterfrom
copilot/add-webview-detection

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 14, 2026

Bowser currently misidentifies Android WebView as Chrome and iOS WebView as Safari. This adds proper detection for both, with Client Hints validation for Android WebView.

Detection approach

  • Android WebView (Chrome WebView): checks hasBrand('Android WebView') from User-Agent Client Hints first (the brand Chromium-based WebViews expose in navigator.userAgentData.brands), then falls back to the UA-string ; wv) canonical marker. Version is extracted from Client Hints when available, otherwise from the Chrome version in the UA string. Descriptor placed before Chrome to prevent false Chrome matches.
  • iOS WebView (iOS WebView): tests for iPhone|iPad|iPod + AppleWebKit without a Safari/ suffix. Standard iOS Safari always includes Safari/XXX; UIWebView and WKWebView do not. iOS does not implement the UA Client Hints API, so UA-string detection is the only available mechanism. Descriptor placed before Safari. Extracts AppleWebKit version.

Files changed

  • src/parser-browsers.js — two new descriptors: Chrome WebView (before Chrome, with Client Hints + UA fallback) and iOS WebView (before Safari, UA-only)
  • src/constants.jschrome_webview/ios_webview added to both BROWSER_ALIASES_MAP and BROWSER_MAP
  • test/acceptance/useragentstrings.yml — 4 new acceptance test cases (Nexus 5 + Samsung Galaxy for Android; iPhone + iPad for iOS)
  • test/unit/parser.js — 4 new unit tests covering Client Hints detection and UA fallback for Android WebView

Usage

// UA string only
Bowser.parse('Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.65 Mobile Safari/537.36');
// browser: { name: 'Chrome WebView', version: '43.0.2357.65' }

// With Client Hints (version comes from hints)
Bowser.getParser(ua, { brands: [{ brand: 'Android WebView', version: '131' }, ...] }).parse();
// browser: { name: 'Chrome WebView', version: '131' }

Bowser.parse('Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/603.1.23 (KHTML, like Gecko) Mobile/14E5239e');
// browser: { name: 'iOS WebView', version: '603.1.23' }
Original prompt

This section details on the original issue you should resolve

<issue_title>Add WebView detection</issue_title>
<issue_description>Detect WebView on Android and iOS.
Android Docs</issue_description>

Comments on the Issue (you are @copilot in this section)

@lancedikson Unfortunately, not. But seems to be quite a wanted feature. I guess I won't have enough time to do it, so it's open for an enthusiastic programmer to code it :) @lancedikson @maerzhase, well, the terms seem very close to me. However, we could add MS Office detection regardless of the webview detection I guess.

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits March 14, 2026 14:27
Co-authored-by: naorpeled <6171622+naorpeled@users.noreply.github.com>
Co-authored-by: naorpeled <6171622+naorpeled@users.noreply.github.com>
Copilot AI changed the title [WIP] Add WebView detection for Android and iOS Add Android and iOS WebView detection Mar 14, 2026
Copilot AI requested a review from naorpeled March 14, 2026 14:33
@naorpeled
Copy link
Copy Markdown
Collaborator

@copilot can we perhaps validate this using clients hints or an additional mechanism?

Co-authored-by: naorpeled <6171622+naorpeled@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 14, 2026

@copilot can we perhaps validate this using clients hints or an additional mechanism?

Done in 37903d2. The Android WebView descriptor now checks Client Hints first:

  • test(): calls parser.hasBrand('Android WebView') — Chromium-based WebViews expose this brand in navigator.userAgentData.brands. Falls back to the UA-string ; wv) marker if no hints are present.
  • describe(): uses parser.getBrandVersion('Android WebView') for the version when Client Hints are available, falling back to extracting the Chrome version from the UA string.

iOS WebView stays UA-only since iOS doesn't implement the UA Client Hints API.

Copilot AI changed the title Add Android and iOS WebView detection Add Android and iOS WebView detection with Client Hints support Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add WebView detection

2 participants