Challenge Overview
This challenge is the third in a series where we will attempt to build the components for a native iOS Mobile Sales App that uses Salesforce Backend. The premise of the of the App is for Corellian Engineering Corporation Salesperson to request sample equipment for their customers (Rebellion Space Pilots) while they are on planets that may not have wifi or any network connectivity. Based on the earlier two challenges, we’ve built an app which allows the user to sign a sample request and store it as an attachment in Salesforce.
Now, we want to extend it further to support syncing using the Salesforce Mobile SDK SmartStore feature.
The winning code from previous challenge and the demo org credentials are provided in the challenge forums. There are 2 primary objectives of this challenge
-
Allow the user to sign a sample request offline and store it in SmartStore. A user should be able to sign a sample request multiple times so you should be able to store multiple signature images/ PDFs offline. The use case here is that a rep may sign thousands of offline requests while NOT having any Internet connectivity. Once, he has Internet, the app should detect the same and upload all signatures to Salesforce in a non-obtrusive manner. Currently, if the user goes offline while signing, the sample request is not signed but the signature is preserved and the user manually needs to press ‘Confirm’ to sync the data to Salesforce. This limitation must go away and the user should be able to sign a sample request in the same manner regardless of whether they’re offline or online. The current online flow for signing must work as is.
-
When Internet Connectivity is available, the app should automatically sync all unsynced signatures with Salesforce. Once syncing is complete, the app should then show a pop-up showing how many sample requests were sync’d up stream to Salesforce and if there were errors if any.
Suggested approach
-
While signing, check whether user is online or not
-
If online, current flow works as is
-
if offline, store the current signature with sample request id, user id and isSynced (set to false) in SmartStore
-
When user has Internet connectivity, check all requests in SmartStore which have isSynced set to false and sync these with Salesforce.
-
If a sample request signature is synced to Salesforce, set it’s isSynced flag to true so it’s not processed in the next offline run
One of the key objectives of this challenge is that the app app must demonstrate that it’s possible to send large number of signature data in an asynchronous and real time manner.
Resources on SmartStore/ Syncing
https://developer.salesforce.com/blogs/developer-relations/2012/11/using-smartstore-with-native-ios.html
https://developer.salesforce.com/docs/atlas.en-us.mobile_sdk.meta/mobile_sdk/entity_framework_native_using.htm