Salesforce

Handling Offline Challenges (Magic xpa 2.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

Handling Offline Challenges (Magic xpa 2.x)

When planning an offline implementation, it is important to understand the challenges and constraints you need to overcome, to enable applications to work completely offline, without a server connection. Unlike a connected application, server connectivity is either non-existent or intermittent, and applications need to be adjusted to handle this scenario properly, without compromising usability and data integrity. These challenges relate to both the technical aspect of being disconnected, and the data consistency aspect, as follows:

  • Storing a subset of relevant server data or client-only data on the client

  • On systems that require user authentication, storing user credentials securely on the client

  • Allowing data entry on the client, while preserving update consistency with server data

  • Providing effective bi-directional sync mechanisms for data

  • Working under intermittent network connectivity (network disconnects, slow connections) while allowing uninterrupted operation and data consistency

  • Keeping application resources (application metadata, image resources and so on) locally on the client, while allowing updates during connectivity periods

The above challenges define an offline pattern that is, in many ways, different from patterns used when network connectivity is guaranteed, and require the developer to handle additional usage scenarios. Magic xpa provides tools and features that allow developers to tackle these challenges and provide a complete offline experience.

Offline Application Pattern

Unlike connected applications, offline applications are designed to work without or with intermittent network connectivity. This limitation defines a different execution flow for offline applications. Typical offline applications will work as follows:

  • On first invocation, offline applications must download and sync all necessary resources required for offline operation. Such resources include application metadata, images, client-side data and so on. This mandatory step requires an offline application to be connected at least once before it can work offline. The developer should make sure that all resources and data required are available at this stage.

  • For applications that require user authentication, user credentials should be securely stored on the client, to allow for operation without server authentication. To ensure validity, cuch credentials should be re-checked when connected.

  • Following initial invocation, all user interactions must be done using local resources only (local data, local images and so on). By using local resources exclusively, the application is guaranteed to work, regardless of the internet connectivity state and without requiring server access. All data updates should be stored locally on the local database.

  • Periodically, at an application-dependent timing, the application must synchronize modified local data back to the server, and download server data that was modified since the last synchronization. Note that if data objects can be updated both by multiple clients and by the server simultaneously, proper conflict resolution should be implemented. A master-master pattern is proposed below to handle offline-style data synchronizations.

  • Since Magic xpa automatically synchronizes metadata objects while connected, an application that runs offline must be allowed to periodically synchronize changes to its metadata objects. Typically, if an internet connection is available on startup, metadata objects will be synchronized automatically. The developer should plan for allowing metadata updates to happen, when the application changes.

The following sections describe, in more detail, how to implement each of the above, and the supporting Magic xpa features that enable each capability.

Terminology and Definitions

In this section, the following terminology is used:

  • Offline program – A program that runs only on the client. This program will not access the server and cannot use server resources.

  • Local data source – A data source pointing to a database that is stored locally on the client.

Reference
Attachment 
Attachment