[SalesForce] Salesforce1 native – How to check if page open in IPAD or in IPhone

I have designed my VisualForce page for Mobile devices(IPhone/Android) as well as IPAD. This is working perfectly on mobile devices(Iphone/Android) via native SF1 app, mobile browser and IPAD Browser.

The issue is When I am opening the same page via SF1 native app from IPAD( iOS 7.1) instead of IPAD View its showing the Mobile view . But the same IPAD view is working fine When I am checking it via IPAD browser (Web link and with one/one.app).

Is there any separate way to differentiate the IPhone/Ipad in SF1 app?

The Way I am doing is by checking User-agent from Server end:

String userAgent = System.currentPageReference().getHeaders().get('User-Agent');
if (userAgent.contains('iPhone')){
     }
    else if (userAgent.contains('iPad')){
    }  //added comment to allow code formatting

Please help.

Best Answer

There is nothing baked into the JavaScript sforce library that would help you. The only solution is the user-agent check that you are performing.