0

Is there a reliable way to check via JavaScript if the user is visiting a website with a device that has a rear camera?

My use case is this: I have AR content on my page. When the user has a desktop or laptop, I want to display a QR code containing a link that he can scan with a mobile device to use the AR feature. But when he uses a tablet or phone I want to directly open the link because his device is already AR capable.

I know I could check the screen resolution. But I think that would not work reliably for different browser window sizes. The best option so far seems to be to parse the user agent for the string "mobile". But isn't there a cleaner way?

jpstrube
  • 785
  • 1
  • 11
  • 27

0 Answers0