Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

42
Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore Developer Track Tom Gersic, Model Metrics / salesforce.com Director, Technical Solutions @tomgersic

Transcript of Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Page 1: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Developing Offline-Capable Apps

with the Salesforce Mobile SDK and

SmartStore

Developer Track

Tom Gersic, Model Metrics / salesforce.com

Director, Technical Solutions

@tomgersic

Page 2: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Safe Harbor

Safe harbor statement under the Private Securities Litigation Reform Act of 1995:

This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties

materialize or if any of the assumptions proves incorrect, the results of salesforce.com, Inc. could differ materially from the results

expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be

deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other

financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any

statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.

The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new

functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our

operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of

intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we

operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new

releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization

and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of

salesforce.com, inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2012. This

documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of

our Web site.

Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently

available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based

upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-

looking statements.

Page 3: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

All About Model Metrics

Now a salesforce.com Company

10 year track record - 2,000+ cloud engagements

Passionate & innovative World-class skills -

CRM, Force.com, Heroku, Radian6, Rypple, iOS

and Android

In-house design studio – ModelFX

Mobile experts - iPhone, iPad and Android

Page 4: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Agenda

• What we are going to build today

• Salesforce Mobile SDK Overview

• SmartStore Terminology and Demo

• SmartStore Behind the Scenes

• Building the app

Page 5: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

What We’re Building Today, and Why

http://www.github.com/tomgersic/HazyPassword

Page 6: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Offline Access

Page 7: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Offline Queuing

Page 8: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Database.com Backend

Page 9: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Salesforce Mobile SDK

Page 10: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Force.com Mobile SDK

Page 11: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Three Options: Which One Is Right For You?

Web developer skills

Access to native platform

App store distribution

Advanced UI interactions

Fastest performance

App store distribution

Web developer skills

Instant updates

Unrestricted distribution

Page 12: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Hybrid Mobile App Development

Page 13: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Force.com Mobile SDK

http://developer.force.com/mobile

Page 14: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Force.com Mobile SDK

https://github.com/forcedotcom

Page 15: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore
Page 16: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

OAuth

An industry standard method of validating user credentials

while avoiding password anti-patterns.

Page 17: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore
Page 18: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

OAuth 2.0 Flows Available

User-Agent Flow

Username-Password Flow

SAML Bearer Assertion Flow

Refresh Token Flow

JWT Bearer Token Flow

Web Server Authentication Flow

Page 19: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

OAuth 2.0 Flows Available

User-Agent Flow

Username-Password Flow

SAML Bearer Assertion Flow

Refresh Token Flow

JWT Bearer Token Flow

Web Server Authentication Flow

Page 20: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

OAuth 2.0 User-Agent Flow

Page 21: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

OAuth 2.0 User-Agent Flow

Page 22: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

OAuth 2.0 Refresh Token Flow

Page 23: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Oauth 2.0 and the Mobile SDK

Page 24: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Representational State Transfer (REST) A stateless data transport based on standard HTTP

methods for delivering data as JSON or XML

Page 25: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

REST API

HEAD is used to retrieve resource metadata.

GET is used to retrieve information, such as SOQL Queries

using SELECT.

POST is used to create a new record.

PATCH is used to update or upsert a record.

DELETE is used to delete a record.

Page 26: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

REST API Returns a JSON Response /services/data/v24.0/query/?q=SELECT Id, Name, Username__c, Password__c,

URL__c FROM Password__c

http://bit.ly/sfworkbench

Page 27: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Salesforce.com Mobile SDK SmartStore

SQLite ORM wrapper for Native and Hybrid apps built on the

salesforce.com Mobile SDK

NoSQL style JSON-based document store

Page 28: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

SmartStore Stack

Page 29: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Smartstore Security

Only cross-platform NoSQL mobile database technology on the

market that comes with encryption built right in.

And if you’re doing a hybrid (Phonegap) app…

Page 30: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

WebSQL

http://caniuse.com/#search=websql

Page 31: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

IndexedDB

http://caniuse.com/#search=indexeddb

Page 32: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

PhoneGap Storage Class

Page 33: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Native Database Technology Encryption

• Encrypt your data yourself using PIN / Passcode

• CoreData/SQLCipher

NSIncrementalStore

Good Dynamics

• FMDB/SQLCipher

Salesforce Smartstore

Page 34: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Terminology

Soup – is a database table used to store JSON documents with

index columns.

Soups are held in Stores, which are SQLite database files.

This is all Apple Newton terminology

It had no real filesystem, so data was stored in database entries called

“soups”

For the interested:

• http://en.wikipedia.org/wiki/Soup_(Apple)

• http://www.canicula.com/newton/prog/soups.htm

Page 35: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Some things you can do with your soup…

• Register a Soup with an IndexSpec

• Query a Soup using a QuerySpec

• Upsert Data to a Soup

• Delete Data from a Soup

• Remove a Soup

Page 36: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

IndexSpec

• JSON Object

• Fields to index

• “string” or “integer” [

{"path":"Id","type":"string"},

{"path":"Name","type":"string"}

]

Page 37: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

QuerySpec

buildAllQuerySpec(path,order,pageSize)

Query all records from the object in the given sort order (or null order) buildExactQuerySpec(path,matchKey,pageSize)

Search for records with index path values matching the key.

buildRangeQuerySpec(path,beginKey,endKey,pageSize)

Return all records with an index path value between the two range values buildLikeQuerySpec(path,likeKey,order,pageSize)

Basically “select * from [table] LIKE ‘%[likeKey]%’”

Page 38: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

SmartStore Demo

Follow along with https://github.com/tomgersic/SmartStoreDemo

Page 39: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

SmartStore Behind the Scenes

Page 40: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Code Walkthrough

http://www.github.com/tomgersic/HazyPassword

Page 41: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore

Tom Gersic

Director, Technical Solutions – Mobile

@tomgersic

Page 42: Developing Offline-Capable Apps with the Salesforce Mobile SDK and SmartStore