0

I'm running into an issue with configuring the Salesforce SDK for Android.

We have a Force.com site that does not require logging in to access (Guest User can open the Visualforce page). I'm trying to build an app that uses the site as its starting page, without attempting to authenticate the app user.

When I set the startPage in bootconfig.js, I'm not also able to set shouldAuthenticate: false to achieve this. I'll hit an error when opening the app:

"SalesforceDroidGapActivity.onResumeNotLoggedIn", "Should not authenticate / remote start page - cannot proceed

Is there any way to configure this to load a remote VF page but not require authentication?

My bootconfig.js:

{
  "remoteAccessConsumerKey": "redacted",
  "oauthRedirectURI": "sdfc://success",
  "oauthScopes": [
    "web",
    "api",
    "visualforce"
  ],
  "isLocal": false,
  // I've tried this as the full URL or just /.
  // My servers.xml is configured for our Force.com site
  "startPage": "/#/resource",
  "errorPage": "error.html",
  "shouldAuthenticate": false,
  "attemptOfflineLoad": false,
  "androidPushNotificationClientId": ""
}
  • Can you post a snippet showing how you're configuring the start page etc. in bootconfig.js? – Benj Feb 29 '16 at 14:26
0

It looks like SalesforceDroidGapActivity.java has an assumption that remote apps must be authenticated, but it may be easy to patch that.

See the definition of onResumeNotLoggedIn (~line 194)

 /**
 * Called when resuming activity and user is not authenticated
 */
private void onResumeNotLoggedIn() {

    // Need to be authenticated
    if (bootconfig.shouldAuthenticate()) {

        // Removed for a simple example...

    }

    // Does not need to be authenticated
    else {

        // Local
        if (bootconfig.isLocal()) {
            Log.i("SalesforceDroidGapActivity.onResumeNotLoggedIn", "Should not authenticate / local start page - loading web app");
            loadLocalStartPage();
        }

        // Remote
        // ASSUMPTION - REMOTE APP MUST BE AUTHENTICATED
        else {
            Log.w("SalesforceDroidGapActivity.onResumeNotLoggedIn", "Should not authenticate / remote start page - cannot proceed");
            loadErrorPage();
        }
    }
}

It might be possible to simple take out that assumption locally on your development machine and see if your app will compile. Try replacing that final } else { statement with the following, and if that works, you can submit a PR to the github repo:

// Remote
// TRY TO LOAD WITHOUT AUTHENTICATION
else {
    Log.i("Try to load an unauthenticated remote app");
    loadRemoteStartPage();
}

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.