Mobile SDK Development Guide
Using Lightning Web Components in Hybrid Apps
Enabling SmartStore in Hybrid and Native Apps
Adding SmartStore to Existing Android Apps
Creating and Accessing User-based Stores
Using Global
Using Arrays in Index Paths
Populating a Soup
Retrieving Data from a Soup
Smart SQL Queries
Working with Query Results
Inserting, Updating, and Upserting Data
Removing Soup Elements
Managing Stores
Testing with the SmartStore Inspector
Using the Mock
Preparing Soups for
Using SmartStore in Swift Apps
Validating Configuration Files
Using Key-Value Stores for Secure Data Storage
Dark Mode and Dark Theme Settings
iOS Current Deprecations
iOS APIs Removed in Mobile SDK 11.0
Android Current Deprecations
Android APIs Removed in Mobile SDK 11.0
Trademark Attributions
Removing UIWebView from iOS Hybrid Apps
Using SmartStore to Securely Store Offline Data
Mobile devices can lose connection at any time, and environments such as hospitals and airplanes often prohibit connectivity. To handle these situations, it’s important that your mobile apps continue to function when they go offline.
Mobile SDK provides SmartStore, a multithreaded, secure solution for offline storage on mobile devices. With SmartStore, your customers can continue working with data in a secure environment even when the device loses connectivity. When you couple SmartStore with Mobile Sync, you can easily keep local SmartStore data in sync with the Salesforce server when connectivity resumes.
-
About SmartStore
SmartStore provides the primary features of non-relational desktop databases—data segmentation, indexing, querying—along with caching for offline storage. -
Enabling SmartStore in Hybrid and Native Apps
To use SmartStore in hybrid Android apps, you perform a few extra steps. -
Adding SmartStore to Existing Android Apps
Hybrid projects created with Mobile SDK 4.0 or later automatically include SmartStore. If you used Mobile SDK 4.0+ to create an Android native project without SmartStore, you can easily add it later. -
Creating and Accessing User-based Stores
When an app initializes SmartStore, it creates an instance of a store. It then uses the store to register and populate soups and manipulate soup data. For a user-based store, SmartStore manages the store’s life cycle—you don’t need to think about cleaning up after the user’s session ends. For global stores, though, your app is responsible for deleting the store’s data when the app terminates. -
Using Global
Although you usually tie a SmartStore instance to a specific customer’s credentials, you can also access a global instance for special requirements. -
Registering Soups with Configuration Files
Beginning with Mobile SDK 6.0SmartStore lets you define soup structures through configuration files rather than code. Since all platforms and app types use the same configuration files, you can describe all your soups in a single file. You can then compile that file into any project. -
Using Arrays in Index Paths
Index paths can contain arrays, but certain rules apply. -
Populating a Soup
To add Salesforce records to a soup for offline access, use the REST API in conjunction with SmartStore APIs. -
Retrieving Data from a Soup
SmartStore provides a set of helper methods that build query strings for you. -
Smart SQL Queries
To exert full control over your queries—or to reuse existing SQL queries—you can define custom SmartStore queries. -
Using Full-Text Search Queries
To perform efficient and flexible searches in SmartStore, you use full-text queries. Full-text queries yield significant performance advantages over “like” queries when you’re dealing with large data sets. -
Working with Query Results
Mobile SDK provides mechanisms on each platform that let you access query results efficiently, flexibly, and dynamically. -
Inserting, Updating, and Upserting Data
SmartStore defines standard fields that help you track entries and synchronize soups with external servers. -
Using External Storage for Large Soup Elements
-
Removing Soup Elements
Traditionally, SmartStore methods let you remove soup elements by specifying an array of element IDs. To do so, you usually run a preliminary query to retrieve the candidate IDs, then call the method that performs the deletion. In Mobile SDK 4.2, SmartStore ups the game by adding a query option to its element deletion methods. With this option, you provide only a query, and SmartStore deletes all elements that satisfy that query. This approach delivers a performance boost because both the query and the deletion operation occur in a single call. -
Managing Soups
SmartStore provides utility functionality that lets you retrieve soup metadata and perform other soup-level operations. This functionality is available for hybrid, React Native, Android native, and iOS native apps. -
Managing Stores
If you create global stores, you’re required to perform cleanup when the app exits. Also, if you create multiple user stores, you can perform cleanup if you’re no longer using particular stores. SmartStore provides methods deleting named and global stores. For hybrid apps, SmartStore also provides functions for getting a list of named stores. -
Testing with the SmartStore Inspector
Verifying SmartStore operations during testing can become a tedious and time-consuming effort. SmartStore Inspector comes to the rescue. -
Using the Mock
To facilitate developing and testing code that makes use of the SmartStore while running outside the container, you can use an emulated SmartStore. -
Preparing Soups for
Soups that exchange information with the Salesforce cloud typically use Mobile Sync for synchronization. To support Mobile Sync, most app types require you to create and manage special soup fields for “sync up” operations. -
Using SmartStore in Swift Apps
You can easily install the basic plumbing for SmartStore in a forceios native Swift project.