Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

how to check the page is loaded in mobile or browser using Apex Class

Be First!
by April 16, 2014 APEX, Mobile, SALESFORCE

how to check the page is loaded in mobile or browser using Apex Class

its achievable with the help of “User-Agent” header properties like below:

 

String userAgent = ApexPages.currentPage().getHeaders().get('User-Agent');
if (userAgent.contains('iPhone')) {
    return 'iPhone-Safari';
} else if (userAgent.contains('iPad')) {
    return 'iPhone-Safari';
} else if (userAgent.contains('Salesforce')) {
    return 'Salesforce';
} else if (userAgent.contains('BlackBerry')) {
    return 'BlackBerry';
} else {    
    return 'other';
}

 

 

(523)

Previous
Next

Leave a Reply