Skip to content

Feat(browser): Add WhatsApp in-app browser detection for iOS & Android - #841

Merged
faisalman merged 2 commits into
faisalman:masterfrom
enekose:feat/whatsapp-inapp-browser
Aug 22, 2026
Merged

Feat(browser): Add WhatsApp in-app browser detection for iOS & Android#841
faisalman merged 2 commits into
faisalman:masterfrom
enekose:feat/whatsapp-inapp-browser

Conversation

@enekose

@enekose enekose commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Prerequisites

Type of Change

Feature: new browser detection rule.

Description

Links opened inside WhatsApp are rendered by its in-app browser, which appends a vendor token to the user-agent string: WA4A/<version> on Android and [WAiOS/<version>] on iOS.

Current behavior: The token is ignored, so the in-app browser is misreported as the underlying engine browser:

Platform Detected as
Android Android Browser 4.0 (from the webview's Version/4.0 token)
iOS Mobile Safari 26.6

New behavior: Reported as WhatsApp with type: "inapp", consistent with the other in-app browsers already supported:

Platform Detected as
Android WhatsApp 2.26.30.97, type: inapp
iOS WhatsApp 2.26.31, type: inapp

Changes

  • src/main/ua-parser.js: one rule added to the WebView section:
    /\bwa(?:4a|ios)[\/ ]([\w\.]+)/i                                     // WhatsApp App for iOS & Android
    ], [VERSION, [NAME, 'WhatsApp'], [TYPE, INAPP]], [
    A single pattern covers both platforms. \b prevents matching mid-token, and the separator class [\/ ] keeps it anchored to the version delimiter.
  • src/enums/ua-parser-enums.js: added WHATSAPP: 'WhatsApp' to BrowserName, per the contributing guide.
  • test/data/ua/browser/browser-all.json: added the two user-agent samples below.
  • Regenerated .mjs / .d.ts and dist/ bundles via npm run build.

Note on prior art

This is unrelated to the WhatsApp link-preview fetcher (WhatsApp/2.23.20.0) requested in #412, which is already detected through ua-parser-extensions. That one is a crawler, but this is the user-facing in-app browser. Both can now be identified independently.

Test

Two real cases added to test/data/ua/browser/browser-all.json:

Mozilla/5.0 (Linux; Android 16; 2311DRK48G Build/BP2A.250605.031.A3; ) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/151.0.7922.83 Mobile Safari/537.36 WA4A/2.26.30.97
Mozilla/5.0 (iPhone; CPU iPhone OS 26_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.6 Mobile/15E148 Safari/604.1 [WAiOS/2.26.31]

Ran npm run build+test, all passing

Impact

No breaking changes, but it is a behavior change for these user agents, the code that currently sees Chrome or Mobile Safari for WhatsApp webview traffic will now see WhatsApp. Consumers keying on browser name for those sessions may want to check type === 'inapp'. This matches how the library already treats every other in-app browser.

No new dependencies. The rule is appended after the existing Bing entry and does not alter the ordering or matching of any other pattern.

Detect the WA4A/<version> (Android) and WAiOS/<version> (iOS) tokens
appended by the WhatsApp in-app browser, reported as an `inapp` type.

@faisalman faisalman left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @enekose thanks for the PR! before I can merge, could you update the commit to include only the source files and remove the automatically generated files? (/dist folder, enum.d.ts, and .mjs files)

Revert the build output (dist bundles, .mjs and .d.ts) so the branch
contains only hand-edited sources. These files are produced by
`npm run build` at release time.
@enekose

enekose commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Hi @enekose thanks for the PR! before I can merge, could you update the commit to include only the source files and remove the automatically generated files? (/dist folder, enum.d.ts, and .mjs files)

It is now updated, please review

@enekose
enekose requested a review from faisalman August 22, 2026 09:05
@faisalman
faisalman merged commit 9a831a5 into faisalman:master Aug 22, 2026
7 checks passed
@enekose
enekose deleted the feat/whatsapp-inapp-browser branch August 22, 2026 12:32
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.

2 participants