webview

The importance of detecting WebView

Data Team

4/3/2024 2:30 PM

User Agent Client Hints Device Detection News

Understand where your content is being displayed

WebView is a system component that allows applications to display a web page directly within the app, rather than opening the link in the default web browser. You may also hear WebView referred to as an in-app browser.

An example of an app that uses WebView is Facebook. The Facebook app has a setting that lets users choose whether to open links with the external browser or in-app.

facebook-webview-setting
Screenshot of the Facebook app settings. The user has not chosen to “open links in external browser”.

Why is detecting WebView important?

The web is changing radically this year with Google phasing out third-party cookies from Chrome, as well as the removal of iOS restrictions on the browser market share.

ios-restrictions
Image source: European Commission, who has designated six companies, including Alphabet (Google’s parent company) and Apple as “gatekeepers”.

At 51Degrees, we recognize the importance of detecting WebView for our customers. The applications that control the WebView may enable a unique identifier to be provided and may change how web content and features are displayed. Some websites may want to behave differently depending on whether the content is shown in WebView or not, as the WebView may interfere with data transfers.

Why is detecting WebView important?

Using device detection, it’s possible to detect WebView using some HTTP headers – we'll cover the User-Agent and User-Agent Client Hints headers.

Continuing with the Facebook app as an example, here is a Facebook app User-Agent with the WebView option enabled:

    Mozilla/5.0 (Linux; Android 14; SM-A146U Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/122.0.6261.88 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/453.0.0.40.107;]

And the User-Agent Client Hints are:

    sec-ch-ua-platform: '"Android"' 
    sec-ch-ua-model: '"SM-A146U"' 
    sec-ch-ua-mobile: ?1 
    sec-ch-ua-platform-version: '"14.0.0"' 
    sec-ch-ua: '"Chromium";v="122", "Not(A:Brand";v="24", "Android WebView";v="122"'

Both HTTP headers include mention of WebView – in the User-Agent string, “wv” indicates WebView. But only the User-Agent references Facebook.

Device detection providers need to consider both the User-Agent and User-Agent Client Hints equally when determining WebView.

Sometimes, there can be conflicting information between the User-Agent and the User-Agent Client Hints. The 51Degrees Data Team manually researches and correct these discrepancies, so you can always trust our data accuracy.

This process happens every day, and you can see what the team have been working on with our device data quality page.

What new features would you like to see?

We value feedback from customers for new features and improvements they’d like to have.

So, what would you like to see from 51Degrees? You can respond to our poll on GitHub or contact us if you’d like a feature not listed.

Answer our poll