0

I'm aware it's a duplicate, but I tried the following:

How to detect the stock Android browser

var navU = navigator.userAgent;

// Android Mobile
var isAndroidMobile = navU.indexOf('Android') > -1 && navU.indexOf('Mozilla/5.0') > -1 && navU.indexOf('AppleWebKit') > -1;

// Apple webkit
var regExAppleWebKit = new RegExp(/AppleWebKit\/([\d.]+)/);
var resultAppleWebKitRegEx = regExAppleWebKit.exec(navU);
var appleWebKitVersion = (resultAppleWebKitRegEx === null ? null : parseFloat(regExAppleWebKit.exec(navU)[1]));

// Chrome
var regExChrome = new RegExp(/Chrome\/([\d.]+)/);
var resultChromeRegEx = regEhttps://www.quora.com/What-is-samsung-s5s-native-browser-Is-it-different-for-different-android-flavorsxChrome.exec(navU);
var chromeVersion = (resultChromeRegEx === null ? null : parseFloat(regExChrome.exec(navU)[1]));

// Native Android Browser
var isAndroidBrowser = isAndroidMobile && (appleWebKitVersion !== null && appleWebKitVersion < 537) || (chromeVersion !== null && chromeVersion < 37);

This doesn't work for above mentioned devices. I get false on Galaxy S5 / S6 native browser.

I also tried (Javascript detect android native browser):

var nua = navigator.userAgent;
var is_android = ((nua.indexOf('Mozilla/5.0') > -1 && nua.indexOf('Android ') > -1 &&     nua.indexOf('AppleWebKit') > -1) && !(nua.indexOf('Chrome') > -1));

This works, but also returns true for Chrome.

I'd like to improve on second piece of code so it returns true only for native browser, not chrome.

According to https://www.quora.com/What-is-samsung-s5s-native-browser-Is-it-different-for-different-android-flavors, S5 and S6 use a browser called "Internet". Is there a way to improve above snippet so it handles this browser as well?

Community
  • 1
  • 1
Tool
  • 12,126
  • 15
  • 70
  • 120

1 Answers1

0

There are lots of "Chromia" out there (as PPK shared here, mentioning HTC's and LG's as well as our Samsung Internet). Samsung Internet isn't the old "stock", a.k.a AOSP, Android browser, but our own Chromium-based browser.

I'm not sure what your intention is in trying to determine if it's Samsung Internet rather than Chrome (Perhaps analytics? Hopefully not for bug fixes?) but you may find this guide to our user agent strings here helpful:

http://developer.samsung.com/internet/user-agent-string-format

poshaughnessy
  • 1,978
  • 3
  • 21
  • 35
  • The main reason I could think of (and the reason I'm viewing this question) is because Samsung Internet requires direct user input in order to play each audio clip, while Chrome requires one direct input, and after that, audio may play at any time. I need to know if the user is on Samsung Internet so that I can provide the best UX possible. – swinn Aug 01 '18 at 13:58