function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Naresh Krishna.ax1176Naresh Krishna.ax1176 

How to get the OS name in salesforce apex ?

Hi All,


We can login to salesforce from any OS like Windows, IMac, Android, etc.

I need to do some specific task based on the logged in user's OS.


Can any one please help me with this.



Marty Y. ChangMarty Y. Chang

Hello, Naresh,


I believe what you're trying to do is called "browser detection".  A quick search on Google can get you started:


Alternatively you can try searching for "browser os detection".  I can't recommend any specific scripts or libraries, so I'll let you look around and try some options to see what you like.  Good luck!




Not 100% reliable, though (depends on what the browser is willing to submit to the server about your experience). You may also have additional headers available from mobile devices.


Try using the following page for diagnostics:


<apex:page controller="headertest">
            <apex:repeat value="{!headers}" var="key">


public with sharing class headertest {
    public map<string,string> headers { get { return apexpages.currentpage().getheaders(); } set; }