+ Start a Discussion
One云One云 

mobile sdk - iOS hybrid app - phonegap dictionary?

Could someone help me understand the purpose of these comments in SalesforceOAuthPlugin.js ? * PhoneGap returns a dictionary with: * accessToken * refreshToken * clientId * userId * orgId * loginUrl * instanceUrl * userAgent What is the PhoneGap dictionary and how can it be used? Is it possible to use navigator.notification,alert() or console.log() to verify the current userId, orgId, or even sessionId?
tstellanova-sfdctstellanova-sfdc

What those comments mean is that your "success" callback will be called with an object (which is just a dictionary of key-value pairs). The listed keys such as "userId" can be accessed on the object passed to your success callback function.

 

So yes, when your success callback is called, you can look at the values such as userId. 

Kevin HawkinsKevin Hawkins

The OAuth PhoneGap plugin just returns a regular Javascript hash map object of name/value strings, to the success callback.  The object will be of the form { "accessToken" : [Access Token value], "refreshToken : [Refresh Token value], ... etc. }.

 

So for instance, if you called:

 

SalesforceOAuthPlugin.authenticate(myLoginSucceededFunc, myLoginFailedFunc, myDefinedOAuthProperties);

 

your success callback could look something like:

 

function myLoginSucceededFunc(pgReturnedOAuthCredentials) {

    alert("loginUrl = " + pgReturnedOAuthCredentials.loginUrl);

}

 

See the bootstrap.html file in the hybrid template for an example of how we use SalesforceOAuthPlugin.authenticate().

 

Cheers,

Kevin