detect-browser icon indicating copy to clipboard operation
detect-browser copied to clipboard

Support for UIWebView for in-app Browsers

Open avcohen opened this issue 5 years ago • 5 comments

Currently calling browser() returns null in this environment.

Issue was found on iOS when navigating to a UIWebView via in-app browsers (Facebook & Snapchat).

avcohen avatar Oct 10 '19 15:10 avcohen

@avcohen thanks for reporting the issue. Any chance you can capture the user agents in that UIWebView so I can investigate further? Unfortunately I have limited access to iOS devices.

DamonOehlman avatar Oct 13 '19 09:10 DamonOehlman

No problem at all. Here's the output from navigator.userAgent:

Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E8301

To note I used this tool to get in there and inspect this.

avcohen avatar Oct 14 '19 16:10 avcohen

@avcohen Thanks mate - out of interest what do you think the version number should be on this detection? It looks like 603.1.30 or 14E8301 would both be valid options. Not being familiar with the platform I'm not really sure.

Additionally, with a bit of reading it looks like UIWebView has been deprecated in favour of WKWebView so I guess I need to be considering that for UA detection also.

DamonOehlman avatar Oct 25 '19 00:10 DamonOehlman

Actually... doing some testing with this locally now, I can see that the UA string provided above already satisfies the current uiwebview regex and thus this is the result returned from detection:

{ name: 'ios-webview', version: '603.1.30', os: 'iOS' }

(obviously I decided the 603.1.30 was the appropriate version number)

I think what is happening is that both Facebook and Snapchat have updated their apps to use the WKWebView and the UA detection is no longer working. I'll see if I can track down the user agent used.

DamonOehlman avatar Oct 25 '19 00:10 DamonOehlman

Also remembering that an app can set a custom useragent also, so... may need a more detailed investigation.

DamonOehlman avatar Oct 25 '19 00:10 DamonOehlman