Developer Preview of Mobile SDK now available!

It is a little over 12 hours since we announced the new Force.com and Database.com Ruby gem, and now it is time for the next developer announcement, the availability of the  Mobile SDK developer preview. Currently, this developer preview supports iOS with support for other platforms in the near future.

In a nutshell, the SDK is comprised of two aspects:

1. Native Mobile libraries

The native mobile libraries provides OAuth 2  support for authenticating against Force.com and Database.com, as well as wrappers for calling the REST API.  Here is a quick example, you can check out the Github repository (Oh, it’s open source ) for more samples and documentation.

SFOAuthCredentials *credentials = [[[SFOAuthCredentials alloc] initWithIdentifier:remoteAccessConsumerKey] autorelease];
credentials.protocol = @"https";
credentials.domain = OAuthLoginDomain;
credentials.redirectUri = OAuthRedirectURI; 
self.coordinator = [[[SFOAuthCoordinator alloc] initWithCredentials:credentials] autorelease];
self.coordinator.delegate = self; 
[self.coordinator authenticate];

Now, we are  authenticated, let’s make a quick request for data using the requestForQuery method to return an NSMutableArray of data.

SFRestRequest *request;
request = [[SFRestAPI sharedInstance] requestForQuery:@"Select id, Name from Album__c"];
[[SFRestAPI sharedInstance] send:request delegate:self];

That’s all you need to get started. The native libraries handle all the rest. (no pun intended!)

2. Mobile Container

If you are a HTML5 developer and want the ability to securely access Force.com and Database.com, plus access local device functionality such as contacts, the Mobile SDK also provides the ability  to wrap a web app inside a thin native container, producing a hybrid application.

function onSalesforceOAuthLogin(event) {
logToConsole("onSalesforceOAuthLogin: Salesforce ready");
forcetkClient = new forcetk.Client(event.data.clientId, event.data.loginUrl);
forcetkClient.setSessionToken(event.data.accessToken, event.data.apiVersion, event.data.instanceUrl);
forcetkClient.setRefreshToken(event.data.refreshToken);
}

Then, fetch some data, like this:

$('#link_fetch_sfdc_contacts').click(function() {
logToConsole("link_fetch_sfdc_contacts clicked");
forcetkClient.query("SELECT Name FROM Contact", onSuccessSfdc, onErrorSfdc);
});

If you are at Dreamforce, make sure you check out the Mobile App Dev area in the DevZone, and come and grab a Mobile workbook which will teach you how to build apps using the new SDK.

Houston, we are go for launch!

 

 

 

 

 

Published
August 30, 2011

Leave your comments...

Developer Preview of Mobile SDK now available!