charlie_says Posted February 28, 2018 Share Posted February 28, 2018 It seems that apple has changed their useragent so it doesn't say Ipad or the like. I'm now finding it a bit hard to differentiate between devices. I don't need super accurate, basically just ipad/iphone/android - is there another way of achieving this? (Alternatively, a fairly robust isDesktop would be fine.) Quote Link to comment Share on other sites More sharing options...
eXponeta Posted February 28, 2018 Share Posted February 28, 2018 You can check platform (mobile (android or iOS) and then compare browser aspect ratio (width / height) , for determining what concrete devices is currently (phone or tablet). For iPad aspect ratio must be near about 4/3 Quote Link to comment Share on other sites More sharing options...
eXponeta Posted February 28, 2018 Share Posted February 28, 2018 var aspect = window.outerWidth / window.outerHeight; Quote Link to comment Share on other sites More sharing options...
charlie_says Posted February 28, 2018 Author Share Posted February 28, 2018 Thanks for the idea - I think quite a lot of monitors would have a 4:3 ratio, which wouldn't necessarily mean it's mobile. I'm trying a slightly different approach... Quote Link to comment Share on other sites More sharing options...
eXponeta Posted February 28, 2018 Share Posted February 28, 2018 IPad has aspect of 4:3 on mobile platform only, other mobile device (include laptops) has 16:9, 21:9,16:10 aspect ratio. // I tested my apps and PIXI.utils.isMobile.any = true on Android and IOS. I haven't iPad, and can't check it, but on iPhone5s it work. Quote Link to comment Share on other sites More sharing options...
bubamara Posted February 28, 2018 Share Posted February 28, 2018 What iOS version are you testing? Looks ok on 11.2.6 var a = PIXI.utils.isMobile.phone; var b = PIXI.utils.isMobile.tablet; console.log(a + ' | ' + b); Quote Link to comment Share on other sites More sharing options...
botmaster Posted February 28, 2018 Share Posted February 28, 2018 3 hours ago, eXponeta said: var aspect = window.outerWidth / window.outerHeight; That's way too loose as a way to check what device your app is running on. Quote Link to comment Share on other sites More sharing options...
eXponeta Posted March 1, 2018 Share Posted March 1, 2018 9 hours ago, botmaster said: That's way too loose as a way to check what device your app is running on. I know it. This simple way how you can determine iPad betwen iOS devices. I thought that this was the main problem. Quote Link to comment Share on other sites More sharing options...
charlie_says Posted March 1, 2018 Author Share Posted March 1, 2018 @bubamara I don't have the device with me today as I'm WFH, but when I had a similar check to you which was returning false | false - when I checked the useragent, there wasn't any mention of iPad in it... Quote Link to comment Share on other sites More sharing options...
charlie_says Posted March 1, 2018 Author Share Posted March 1, 2018 Also - just to give some further detail about this issue. What I needed to do was open a pdf in a new tab (window.open('path/to/my.pdf', '_blank');) which worked fine on desktop but failed on ios - which blocks it as a popup. In that case what I wanted to was just navigate to the pdf (window.location.href = 'path/to/my.pdf';) which works fine everywhere I tested so far. My solution: if ( !window.open('path/to/my.pdf', '_blank') ) { window.location.href = 'path/to/my.pdf'; } Quote Link to comment Share on other sites More sharing options...
bubamara Posted March 1, 2018 Share Posted March 1, 2018 @charlie_says ios 11.2.6 and the UA strings iPad : Mozilla/5.0 (iPad, CPU OS 11_2_6 .... ) iPhone : Mozilla/5.0 (iPhone, CPU OS 11_2_6 .... ) if you want to check iPad only : PIXI.utils.isMobile.apple.tablet Quote Link to comment Share on other sites More sharing options...
bubamara Posted March 1, 2018 Share Posted March 1, 2018 and to prevent popup blocking read more about trusted events here : https://www.w3.org/TR/DOM-Level-3-Events/#trusted-events Quote Link to comment Share on other sites More sharing options...
charlie_says Posted March 1, 2018 Author Share Posted March 1, 2018 thanks @bubamara- I tried opening the PDF a number of different ways (by which I mean how I called window.open), and failed to get it to work. And those would be the UAs I was expecting, but that isn't what I was seeing. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.