Use User.UITheme and UserInfo.getUiTheme() to Determine User Experience Context

The User.UITheme and User.UIThemeDisplayed global variables and the UserInfo.getUiTheme() and UserInfo.getUiThemeDisplayed() Apex utility methods are improved to support the Salesforce1 mobile app and Lightning Experience.
These existing variables and system calls have expanded the range of return values to support the new user experience contexts. Possible return values include the following.
  • Theme1—Obsolete Salesforce theme
  • Theme2Salesforce Classic 2005 user interface theme
  • Theme3Salesforce Classic 2010 user interface theme
  • Theme4d—Modern “Lightning ExperienceSalesforce theme
  • Theme4tSalesforce1 mobile Salesforce theme
  • PortalDefaultSalesforce Customer Portal theme
  • WebstoreSalesforce AppExchange theme

These global variables and system calls can replace other, more fragile methods of detecting the user experience context, such as testing for the presence of the sforce.one JavaScript global. Use them to write Visualforce pages and apps that adapt to the user experience context in which they’re running.