-1

I know that I can use UserInfo.getUiThemeDisplayed() to get the current theme displayed to the user. This works in lightning and classic. However when I am in mobile mode, I just get "Theme4t" (as stated in the documentation.)

Theme4t— Salesforce mobile app theme.

This doesn't give me any information about the type of theme displayed to the current user. How can I get the theme even if I am in mobile mode? (either classic or lightning theme)

0

This is what's returned for mobile, a known issue. According to the SF documentation, to check between the Classic and LEX UI, verify if the "sforce.one" JavaScript object is available. This object would not be available in the Classic UI. If you want to render content specifically for mobile try something like this...

<apex:variable var="uiTheme" value="SalesforceApp" 
    rendered="{!$User.UIThemeDisplayed == 'Theme4t'}">
    <apex:stylesheet value="{!URLFOR($Resource.AppStyles, 
                                     'mobile-styling.css')}" />

Related Trailhead: https://trailhead.salesforce.com/en/content/learn/modules/lex_dev_visualforce/lex_dev_visualforce_multipurpose_pages

  • My question was to differentiate between lex and classic. anyway I tested using your method and this seems to work. Results: classic only = false classic+mobile = false lex = true lex+mobile=true – peter Jun 15 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.