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
Chun Ming Kong 8Chun Ming Kong 8 

Visualforce page in Hybrid App

From the offical documentation, I think there are two ways to access Salesforce data from a hybrid app:
a. REST API
b. download a Visualforce page which connects to a Apex controller to query data
(Please correct me if my understanding is invalid.)

As we do not want to consume vast amout of API calls, we are trying to access the Salesforce data through a VIsualforce page. However, there are no specific documentation to walkthrough the ways to 'embed' a Visualforce page into a hybrid app. We tried to directly open the page (.../apex/page) through an in-app browser but sometimes this requires extra login despite the fact that the login process is completed when the app starts.

Anyone knows the correct way to open a Visualforce page inside a hybrid app?


 
Ashish KumarAshish Kumar
Hi Chun Ming Kong,

You can query your salesforce org data using ForceJS. However if you want to use visualforce pages residing on salesforce and running on app then you might look for hybrid remote app. 
In hybrid remote apps you just have to  provide the start page for the app i.e. relative path of vf page name and from there app continues with the flow and it automatically fetches the corresponding vf pages from the server.

Below links might help you:
Sample App using ForceJS:
https://developer.salesforce.com/docs/atlas.en-us.noversion.mobile_sdk.meta/mobile_sdk/dev_hybrid_apps_run.htm
Hybrid Remote app:
https://developer.salesforce.com/docs/atlas.en-us.noversion.mobile_sdk.meta/mobile_sdk/hybrid_develop_hybrid_remote.htm

Hope it helps, if it does please mark it as a best answer.

Regards,
Ashish Kr.
 
Todd Halfpenny MCTodd Halfpenny MC
If you're consuming Visualforce pages in your hybrid app then you could use Visualforce Remoting (https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_js_remoting.htm) to post/get data. VF remoting calls do not count towards API usage, I believe.

You should be able to re-direct to the Visualforce from within JS, like this
location.href = <YOUR-VF-PAGE>
This does come with its own quirks though (i.e. making sure that you handle scenarios where orgs migrate)