0

I know you can use libraries such as mobile-detect.js, but it fails when you change the viewport display option on your chrome developer tools.

I would like to create a crowdsourcing task that needs to be completed using a phone, and I want to ensure people don't cheat and use their computers instead.

Is there a way to detect if the user is browsing using an actual mobile device?

Algorithmatic
  • 1,568
  • 2
  • 19
  • 37
  • Most browsers have plug-ins available that allow the client to change headers so avoiding cheats might be difficult. Maybe build an actual mobile application? – NewToJS Apr 30 '18 at 01:44
  • 3
    Possible duplicate of [Detecting a mobile browser](https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser) – ibrahim tanyalcin Apr 30 '18 at 01:45
  • @ibowankenobi Thanks, but it's different. Their solution fails when you use chrome's dev tool. – Algorithmatic Apr 30 '18 at 01:49
  • @NewToJS Unfortunately it is probably against the terms of services to require users to install an application. – Algorithmatic Apr 30 '18 at 01:50
  • Unfortunately, there's no fool-proof way to do this. There's always ways to modify headers, so if someone really wants to cheat, they're probably going to find a way. Not only that, but a savvy user could circumvent any JavaScript-based technique for performing such a check. You can make it harder by doing other things like checking user-agent strings, if touch events are supported, etc., but you can't really eliminate all chance of cheating. – JoshG Apr 30 '18 at 02:21
  • @AndroidNoobie I understand that, but is there a way to make it as hard as possible/impossible through just using the browser inspect tool? How does https://emojiscavengerhunt.withgoogle.com/ do it? – Algorithmatic May 11 '18 at 00:16
  • 1
    They appear to be just checking the user agent string, like user ibowankenobi originally suggested. Take a look at https://github.com/google/emoji-scavenger-hunt/blob/master/src/js/utils.ts. I changed my user agent to Android on my laptop using the dev tools in Chrome and it indeed interpreted me as a mobile user. – JoshG May 11 '18 at 01:58

0 Answers0