• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

HTML5 Detecting mobile devices in HTML5 in iPad OS

A

arfeigenbaum

Guest
Hello,

Before iOS 13 (and iPad OS) I had no problem detecting if a user was on mobile or desktop, which I use to show mobile or desktop controls in HTML5 games. Recently, because of iPad OS, iPad is coming up the same way as mac desktop. If I press "request mobile site" on the iPad, I get the right controls, but I would not expect users to think to do that. Does anyone have a solution for identifying mobile vs desktop that works for iPad OS?

I'm using GM Studio 2.

Thanks!
Alex
 

Ricardo

Member
If you go to Settings -> Safari -> Request Desktop Website you'll see the option "Other Websites" is enabled by default. This is Apple trying to force Desktop class browsing experience on iPad OS and it is not a GMS2 bug.
Try to google "ipad os" useragent. There are a lot of threads and devs complaining about this change.

If there exists a reliable workaround for this (I haven't really looked into it), you'll probably find it as a JS function you could add to your project by creating an extension yourself.
 

Ricardo

Member
Btw, take a look at UAParser.js. I'm using it in a HTML5 project and I just verified it correctly detects my iPad as "mobile". So that should do the trick for you.
You can easily create a JS extension and call uaGetDevice() to get what you need.
 
A

arfeigenbaum

Guest
Btw, take a look at UAParser.js. I'm using it in a HTML5 project and I just verified it correctly detects my iPad as "mobile". So that should do the trick for you.
You can easily create a JS extension and call uaGetDevice() to get what you need.
Thank you! I will take a look a that.

It's not a GMS2 bug in the sense that it didn't break on the GMS2 side, but it is a GMS2 feature that no longer works for the purpose that it intends to. It is something I hope that they fix in an update so that it can return iPad OS or something similar, instead of mac os x for the iPad.
 
Btw, take a look at UAParser.js. I'm using it in a HTML5 project and I just verified it correctly detects my iPad as "mobile". So that should do the trick for you.
You can easily create a JS extension and call uaGetDevice() to get what you need.

Hi Ricardo,

Can you help point me in the direction of where I'm messing up here? I'm trying to get this extension working in my project but no luck.

When I try to call it the game crashes.

upload_2020-2-24_18-43-4.png
 

Ricardo

Member
Alright, iPad OS detection IS actually broken in UAParser 0.7.21 too. My bad. However, there's a thread in their github about the issue and someone posted a workaround that seems to be doing the trick (at least it works on my iPad Air 3). You should follow that discussion as they can release a better/more reliable way to detect iPad OS in a future version.

As for now, I've created a small GMS2 project showing how UAParser works for anyone to see. Download here.
In my example, the script returns "mobile" when it detect iPad OS. This can be easily changed directly in ua-parser.min.js, line 21, though.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
So I'll also be waiting for an update on yoyogames.
You might be waiting a while... First, it's not exactly a YYG issue, as this is another "Apple Knows Better Than The User" situation, so GMS2 is actually working as it should given the information that Apple is supplying in their APIs. Second, has anyone actually filed a bug report to inform YYG that this is happening? It may be that they CAN add in a workaround or a check to detect this... ;)
 
You might be waiting a while... First, it's not exactly a YYG issue, as this is another "Apple Knows Better Than The User" situation, so GMS2 is actually working as it should given the information that Apple is supplying in their APIs. Second, has anyone actually filed a bug report to inform YYG that this is happening? It may be that they CAN add in a workaround or a check to detect this... ;)
Hm ... It's true, maybe nobody has opened a call, I'm going to do that now. GMS2 has os_device device_ios_ipad, will it work with HTML5?
 

Ricardo

Member
Second, has anyone actually filed a bug report to inform YYG that this is happening? It may be that they CAN add in a workaround or a check to detect this... ;)
I always keep an eye on Mantis and I actually saw a bug a while ago about this being closed as "no change required". There's still some info you can get through JS to identify an iPad (as the example I posted shows), but Apple could break that workaround at any moment with an iOS update, I believe.

The thing is that Apple wants iPad OS' Safari to be identified as desktop instead of "mobile", so the problem is in the browser's user agent and on Apple's approach on this matter. I really hope Apple realize they're creating problems for several services and users, and hopefully, in the future, iPad OS' Safari could include some extra info in the user agent allowing the iPad to be identified in a reliable way.
 
Last edited:
Top