Device Detection With Devicedetect.js In Salesforce

Device Detection With Devicedetect.js In Salesforce

A good responsive design in UI can render behaviour across different screen sizes. Though there are few edge cases in Salesforce development, especially where you want to redirect traffic to a mobile-specific page, detect the device and even detect Salesforce1 Application itself.

You can probably do this with the help of a library known as DeviceDetect.js Inspired by isMobile.js. Upload it as a static Resource and then refer it in your Visualforce Page.<apex:includeScript value="{!URLFOR($Resource.DeviceDetect, '/js/deviceDetect.min.js')}" />

1.)  Opened in Phone Check:


2.) Opened in Tablet Check:


3.) Opened in Desktop Device Check:


4.) Opened in Salesforce1 Check:


Call the methods as shown below to detect devices and context:

Screenshot from 2018-01-30 18:41:14

“What are your super powers again? – I can Detect Devices" 


Popular Salesforce Blogs