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

Does not detect iOS on newer versions

Open roblourens opened this issue 4 years ago • 4 comments

The useragent alone is no longer sufficient for detecting iOS. Seems like the general recommended technique is to check maxTouchPoints.

https://stackoverflow.com/a/58065241/129895

I don't have an iOS device to test, so I don't want to submit a PR right now, I just have a report that this isn't working for a user's iPad.

roblourens avatar Apr 05 '21 18:04 roblourens

Same issue here

nicoknoll avatar Apr 21 '21 10:04 nicoknoll

@roblourens @nicoknoll Any chance you can both provide a bit more of an example of the kinds of things you are tailoring in your apps/sites once you know it is an iPad? Just trying to work out how a combination of UA sniffing and feature detection might be combined to help solve these use cases.

My thinking is that rather than updating detect-browser to attempt to definitively identify a particular browser, I should look to include a section of the repo that outline "recipes" for being able to detect a particular type of device should detect-browser fail to do it for you.

DamonOehlman avatar Sep 16 '21 23:09 DamonOehlman

Not one of the people you asked, but I just stumbled across this so below is one of my use cases:

  1. I allow users to record a video of themselves and upload it to my app. When viewing from a desktop (any browser) you're presented with a button to record yourself (using https://collab-project.github.io/videojs-record) and another button to upload a file you've recorded offline.
  2. On iOS, the built in file upload allows you to record yourself using the front-facing camera if you set the accept to a video format, so we choose to hide the videojs-record functionality and only use the built-in features.

To handle the behaviour in (2) we can't rely on looking for Safari because both Desktop and iOS Safari report as the same version, but have different behaviour with their input=file support. We also don't seem to be able to feature detect browser support for accept=video so we have to fall back on the maxTouchPoints.

jagregory avatar Sep 19 '21 06:09 jagregory

I just remembered another use case of mine: providing device specific instructions to users. With the example above the user is prompted to give permission for the site to access their camera and microphone; if they decline this access, we need to give them instructions how to change the setting later, which is quite a different set of steps for iOS vs Mac.

jagregory avatar Sep 19 '21 08:09 jagregory