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
koirakoira 

Hybrid app using Mobile Components for Visualforce library, not working

Hi, 

 

I have installed the Mobile Components for Visualforce library and created an Hybrid iOS app which I am trying to launch on an iPad straight into the sample Visualforce page (MobilePage)  like this:

 

var startData = new SFHybridApp.RemoteAppStartData("https://na15.salesforce.com/apex/MobilePage");

 

However, all what I see after launching the app is a blank screen.

 

Just to let you know that  I did manage to get the sample app (Contact viewer) working in the browser and also when I replace the '/apex/MobilePage' in my Hybrid app with any of my other Visualforce pages the Hybrid app does land straight into that page on launch.  

 

Any help will be much appreciated.

 

Thanks.

Gaurav KheterpalGaurav Kheterpal

Do you see any errors? Can you try putting in some logs to see till where your code is executing without hitting any error?

Kevin HawkinsKevin Hawkins
RemoteAppStartData should only contain the path portion of your page. In your example, you should have:

var startData = new SFHybridApp.RemoteAppStartData("/apex/MobilePage");

The authentication process takes care of determining your full URL, based on the user information returned from the process.
koirakoira

Thanks for the suggestion, I tried it but no success. However I was able to fix the problem by modifying the config.xml by adding the following line (in green). 

 

    <access origin="*.force.com" />

    <access origin="*.salesforce.com" />

    <access origin="*" />

 

I wonder this is linked somehow to the installation step where it asks to configure a remote access point for Contact viewer app?

 

...

 

Finally you need to configure a remote access point in your Salesforce org,

 

  1. Log into your org and cick Setup > Administration Setup > Security Controls > Remote Site Settings.

  2. Click New Remote Site, then create a new site by specifying your org's instance URL for the Remote Site URL. For example, if your org is on instance NA1, the Remote Site URL will be https://na1.salesforce.com. 
...

(Ch 7 - Hybrid Development with Mobile Components for Visualforce, pg 84,  http://wiki.developerforce.com/page/Salesforce_touch_platform).

 

Actually, I don't understand why this step is required in the first place.

 

Thanks.

 

 

 

 

 

Kevin HawkinsKevin Hawkins

Changing the access configuration changes which hosts will be whitelisted for access, which is a Cordova security measure.  Does your app access content that lives outside of the salesforce.com and force.com domains?

koirakoira

Yes, actually the log  in Xcode console window does suggest there are calls to googleapis. I wonder where these calls come from, I have not changed anything in the sample app (Contact viewer, MobilePage) and strangely enough there is no mention in the book about modifying the config.xml in order to be able to run this sample hybrid app on the device!

 

....

2013-04-03 17:12:54.511 CloudTunes[5568:907] DEBUG|0|SFHybridViewController|webView:shouldStartLoadWithRequest: Loading URL 'https://c.na15.visual.force.com/apex/MobilePage?context=container'

2013-04-03 17:12:55.608 CloudTunes[5568:2103] ERROR whitelist rejection: url='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'

2013-04-03 17:12:55.609 CloudTunes[5568:2103] ERROR whitelist rejection: url='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'

2013-04-03 17:12:55.611 CloudTunes[5568:2103] ERROR whitelist rejection: url='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'

2013-04-03 17:12:55.616 CloudTunes[5568:2103] ERROR whitelist rejection: url='https://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js'

2013-04-03 17:12:55.618 CloudTunes[5568:2103] ERROR whitelist rejection: url='https://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js'

2013-04-03 17:12:55.620 CloudTunes[5568:2103] ERROR whitelist rejection: url='https://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js'

2013-04-03 17:13:11.577 CloudTunes[5568:907] DEBUG|0|SFHybridViewController|webViewDidFinishLoad: Loaded https://c.na15.visual.force.com/apex/MobilePage?context=container

2013-04-03 17:13:11.578 CloudTunes[5568:907] INFO|0|SFHybridViewController|Checking https://c.na15.visual.force.com/apex/MobilePage?context=container as a 'home page' URL candidate for this app.

2013-04-03 17:13:11.579 CloudTunes[5568:907] INFO|0|SFHybridViewController|Setting https://c.na15.visual.force.com/apex/MobilePage?context=container as the 'home page' URL for this app.

 

akhilesh_sfdcakhilesh_sfdc

Those whitelists are required to pull the required jquery libraries on this app. This has been mentioned in the setup steps of the readme: https://github.com/forcedotcom/MobileComponents/tree/master/Visualforce#salesforce-mobile-container-setup

 

These steps of whitelisting have changed though a bit since our latest releases of SDK. Hope this helps!

koirakoira

Thanks for the clearification.

 

Insturctions in the readme needs updating as we now use config.xml instead of PhoneGap.plist and we need to whitelist ajax.googleapis.com instead (or in addition to) code.jquery.com. For me it works fine even without code.jquery.com.