Initializing Offline Support

Initializing Offline Support

You can enable offline support in the Backend Services JavaScript SDK when instantiating the main SDK object (the Everlive instance). The offline support-related settings allow you choose offline storage type, offline files storage path, and encryption among others.

Even if you enable offline support, the SDK works in online mode by default, the only difference being that it automatically makes an offline copy of the requested data. You need to switch mode explicitly to start working with offline data.

The simpler way is to set the offline option to true which enables offline support using default settings (see API Reference for details):

var el = new Everlive({
    appId: 'your-app-id',
    offline: true
});

You can also pass advanced settings. To see all available configuration settings, as well as their default values, check the API Reference.

The following example sets a storage provider for content types, an encryption provider, and storage paths for offline files:

var el = new Everlive({
    appId: 'your-app-id',
    offline: {
        storage: {
               provider: Everlive.Constants.StorageProvider.LocalStorage
        },
      encryption: {
             provider: Everlive.Constants.EncryptionProvider.Default
      },
        files: {
            storagePath: 'storageDirName', //nested path is possible but parent directories must exist, e.g. files/content
            metaPath: 'metaDirName' //nested path is possible but parent directories must exist, e.g. files/meta
        }
    }
});

For Hybrid apps ensure that the Cordova Files plug-in is enabled when using the files option or the FileSystem provider.

See Also

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.