developing offline mobile apps with salesforce mobile sdk smartstore

30
Developing Offline Mobile Apps Tom Gersic Mobile Practice Director @tomgersic Follow along here! https://github.com/tomgersic/dialer

Upload: tom-gersic

Post on 24-Jun-2015

2.458 views

Category:

Technology


2 download

DESCRIPTION

At some point, all mobile app users lose their data signal. Join us to learn best-practices for coding for offline requirements with the Salesforce Mobile SDK. We'll develop a simple app using SmartStore offline storage, highlighting the SmartSQL and SmartSync features. With these tools, you can take your mobile apps to the next level, developing native and hybrid applications on iOS and Android that have offline access to your data.

TRANSCRIPT

Page 1: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Developing Offline Mobile AppsTom Gersic

Mobile Practice Director

@tomgersic

Follow along here!

https://github.com/tomgersic/dialer

Page 2: Developing Offline Mobile Apps with Salesforce Mobile SDK 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 any litigation, risks associated with completed and any 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-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These 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 Mobile Apps with Salesforce Mobile SDK SmartStore

Tom GersicMobile Practice Director

@tomgersic

Page 4: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

What are we doing here?

•What we are going to build today•Talk a little about offline•Salesforce Mobile SDK Overview•SmartStore Terminology•SmartSync Terminology•Walking through some code

Page 5: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

“I need this data, but my connection is awful!!!”

Page 6: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Why offline? Go where your customers are.

Page 7: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Field Usage Analytics

Page 8: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

What we’ll build todayhttps://github.com/tomgersic/dialer

Page 9: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Google Polymer

<my-element></my-element>

https://github.com/tomgersic/polymer-helloworld

Page 10: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Google Material Design Language

Page 11: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Polymer Hello World•https://github.com/tomgersic/polymer-helloworld•bower init•bower install --save Polymer/polymer•bower install --save Polymer/core-elements•bower install --save Polymer/paper-elements•python -m SimpleHTTPServer•http://localhost:8000/

Page 12: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Customer DataSalesforce.com Mobile SDK

Page 13: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Three Options: Which One Is Right For You?

Web developer skillsAccess to native platformApp store distribution

Advanced UI interactionsFastest performanceApp store distribution

Web developer skillsInstant updatesUnrestricted distribution

Page 14: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

It’s all about soup

SQLCipher

SQLite

SmartStore

Page 15: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Soups• Hold Indexed JSON Documents• JSON Responses can encompass data from multiple tables

Id Soup Created lastModified Index 1 Index 2 Index N…

1 {JSON} 1371069899796 1371070436125 a00E0000009Xj2mIAC Salesforce.com …

2 {JSON} 1371069899802 1371070436126 a00E0000009Xj36IAC Facebook …

3 {JSON} 1371069899803 1371129103154 a00E0000004h2MnIAI Google …

Page 16: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

REST API Returns a JSON Response

/services/data/v29.0/query/?q=SELECT Id, Name FROM Contact

Page 17: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Soups and Stores

Page 18: Developing Offline Mobile Apps with Salesforce Mobile SDK 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 19: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

IndexSpec• JSON Object• Fields to index• “string” or “integer”• [• {"path":"Id","type":"string"},• {"path":"Name","type":"string"}• ]

Page 20: Developing Offline Mobile Apps with Salesforce Mobile SDK 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]%’”

buildSmartQuerySpec(smartSql,pageSize)Basically “select * from [table] LIKE ‘%[likeKey]%’”

Page 21: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

SmartSQL•SELECT {departments:name}, {employees:lastName}•FROM {employees}, {departments}•WHERE {departments:deptCode} = {employees:deptCode}•ORDER by {departments:name}, {employees:lastName}

Page 22: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

SmartSync

Page 23: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

SmartSync• Extends Backbone.js• Can be used with or without a SmartStore Cache• Queries returned as Backbone Model Collections

Page 24: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Backbone• MV* Framework

• Models: Individual records• Collections: Collections of Model records

• View: Javascript backing for the stuff that you see• Router: routes everything after the # in a URL to application functions

• http://myapp.com/#/user/list

Page 25: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Force.SObject• sobjectType: Account, Opportunity, etc.• fieldlist: ["Id", "Name", "Amount", "StageName"]• cacheMode: client, server write order• mergeMode: how to handle conflicts• cache: if using SmartStore• cacheForOriginals: backup data for conflict detection

Page 26: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Force.SObjectCollection• config: determines queries used to access data• cache: if using SmartStore• cacheForOriginals: backup data for conflict detection

Page 27: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Force.StoreCache• soupName: Name of the SmartStore Soup• additionalIndexSpecs: IndexSpecs to use, in addition to defaults• keyField: Name of the field containing the record Id

• __locally_created__• __locally_updated__• __locally_deleted__• __local__ (set to true if any of the previous three are true)

Offline Fields

Page 28: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Patterns for Offline Success

Page 29: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore

Offline Queueing

Page 30: Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore