0

How do I get the URL (specifically the parameters) into my Controller from a VF Page when the device is a mobile phone? The VF Page is housed on a Community Page. I can get the URL param just fine when on Desktop using: ApexPages.currentPage().getHeaders().get('referer'); But when I am using mobile (when UserInfo.getUiTheme() == 'Theme4t'), then this value is null.

I have attempted all of these on my mobile device and NONE work... failed mobile attempts

The following solution only works for desktop with 1 parameter: ApexPages.currentPage().getHeaders().get('referer').substringAfter('?param=');

But I really need this to work for a mobile device.

Any suggestions?

Thank you.

0

If you want to get URL parameters, doesn't this work?

String param = System.currentPageReference().getParameters().get('param');
1
  • This method does not actually work from inside a Community, both Desktop and Mobile (both android and ios) it seems this method is not available. The line you suggested returns NULL. I also tried to put mobile in 'desktop mode', but that didn't seem to work either. Thanks again for your response, any other suggestions? I'm beginning to think this is absolutely impossible to get a URL param value on Mobile. Desktop >> String param = ApexPages.currentPage().getHeaders().get('referer').substringAfter('?param='); This is a null pointer exception on Mobile because 'referer' is not a header value.
    – Spatula
    Mar 14 at 14:25
0

My Resolution: To my understanding this is NOT possible to get the URL param into the Controller of a VF Page embedded in a Community Page while User is on a Mobile device.

To know if the User is on Desktop or Mobile I found this question which was useful (more info). I found someone else had this issue with Salesforce1. Another question, but not Mobile related. I did the following that this link suggested, but still no resolution (hence my initial screenshot testing all sorts of ways to get this value...).

I hope someone can prove me wrong though and give insight on how to do this. Thank you!

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.