[Bug]: Changing the user-agent in the mobile application (Android)

Hello!
When redirecting to a mobile application according to the documentation (through opening a deep link in a dapp), I have the following problem:

the first request to the page has user agent
Mozilla/5.0 (Linux; Android 12; SM-F711B Build/SP1A.210812.016; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/111.0.5563.58 Mobile Safari/537.36 , and the fetch request following it has a user agent
Mozilla/5.0 (Linux; Android 12; SM-F711B Build/SP1A.210812.016; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/111.0.5563.58 Mobile Safari/537.36 WebView MetaMaskMobile

so far I have noticed such a problem only on Android.
MetaMask app version 6.1.1

It is important for me that the user-agent are the same.
how can i get it?

Hello @nmmikhaylovskiy !
Welcome to MetaMask community !

What user-agent do subsequent connections show?
As we can see, the user-agent is identical for both requests, except for adding " WebView MetaMaskMobile at the end.
You may implement client side or server side validation like this:

const {clientUserAgent, ...rest} = await getProfile();

const currentUserAgent = window.navigator.userAgent;

if(currentUserAgent === clientUserAgent || 
   currentUserAgent === `${clientUserAgent} WebView MetaMaskMobile`) {
        console.log("User agent is same!")
        // any success action
} else {
    console.log(`User agent isn't same`)
        // any redirect action
}
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.