Magento – How to give user agent rule for iPad and Tablet in Magento 2.1

magento-2.1mobilerulestheme

I have two themes, one for mobile and other for desktop. I have created 2 user agent rules for Mobile and iPad. All mobiles are showing mobile theme. But iPad and Tablets are also showing mobile theme. I need iPad and Tablets to show desktop theme. Can anyone please help me to fix this issue?

enter image description here

Best Answer

This is because the mobile user agent includes the iPad. To workaround this you'll need to specify the mobiles individually.

Note that the Safari on iPad user agent string contains the word "Mobile", but does not contain the word "iPhone". If you are currently serving mobile content to any browser that self-identifies as "Mobile", you should modify your user agent string checks to look for iPad and avoid sending it the wrong version of your site.

For example:

Mobile theme

iPhone|iPod|BlackBerry|BB10|Pre|Palm|Googlebot-Mobile|mobi|Safari Mobile|Windows Mobile|Android|Opera Mini|mobile

Desktop theme

iPad|Silk|Kindle|Xoom|SCH-I800|GT-P5210|Android Tablet|Tablet|SM-T520|hudl|HT7S3|ME173X|JSS15Q|Nexus 7|Nexus 8|Nexus 9|Nexus 10

If that doesn't work try also removing mobi. That list is a few years old now so you may need to add some more if you find new devices aren't working as you'd expect.

Some info taken from this M1 answer

Related Topic