DamonOehlman / detect-browser

Unpack a browser type and version from the useragent string

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for UIWebView for in-app Browsers

avcohen opened this issue · 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 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.

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 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.

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.

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