I need to tell what browser the users are using for my website. (edit: Users need to add a bookmarklet, which is not possible on the standard 'internet' browser. I need to know what message to show them.)
EDIT: I don't need to be able to detect any kind of browser. Specifically I need, in this case, to be able to detect whether a browser is truly a Google Chrome browser.
For at least one smart device, I am having trouble telling the difference between the stock 'internet' browser and Chrome; Both contain the word 'Chrome'.
Samsung galaxy s5:
Stock browser user agent:
Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG-SM-G900A Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36
Chrome user agent:
Mozilla/5.0 (Linux; Android 4.4.2; SAMSUNG-SM-G900A Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.128 Mobile Safari/537.36
"Version/X.x" is different, but will that always be the case?
Edit: I did already check for previous answers as suggested in the comments. They assume that the non-Chrome browser does NOT contain the word Chrome.
So the difference is this in the user agent:
Version/X.X
From https://developer.chrome.com/multidevice/user-agent#webview_user_agent:
"If you’re attempting to differentiate between the WebView and Chrome for Android, you should look for the presence of the Version/X.X string in the WebView user-agent string."
I suppose a Chrome webview browser can still choose to leave that bit out, but if it DOES have it, then at least I know it isn't true Google Chrome!
Please check this link: https://developer.chrome.com/multidevice/user-agent In the last paragraph we find:
If you’re attempting to differentiate between the WebView and Chrome for Android, you should look for the presence of the Version/X.X string in the WebView user-agent string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With