Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Cloud Settings

Improve this doc

Stores app settings in cloud storage so if the user re-installs the app or installs it on a different device, the settings will be restored and available in the new installation.

Repo: https://github.com/dpa99c/cordova-plugin-cloud-settings

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-cloud-settings --variable ANDROID_BACKUP_SERVICE_KEY=myapikey
    $ npm install --save @ionic-native/cloud-settings@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { CloudSettings } from '@ionic-native/cloud-settings';


constructor(private cloudSettings: CloudSettings) { }

...

this.cloudSettings.exists()
  .then((exists: boolean) => console.log("Saved settings exist: " + exists) )

this.cloudSettings.load()
  .then((settings: any) => this.settings = settings)
  .catch((error: any) => console.error(error));

this.cloudSettings.save(this.settings)
  .then((savedSettings: any) => console.log("Saved settings: " + JSON.stringify(savedSettings)))
  .catch((error: any) => console.error(error));

Instance Members

exists()

Indicates if any stored cloud settings currently exist for the current user.

Returns: Promise<boolean> Will be passed a boolean flag which indicates whether an store settings exist for the user.

save(settings, overwrite)

Saves the settings to cloud backup.

Param Type Details
settings object

a JSON structure representing the user settings to save to cloud backup.

overwrite boolean

(optional) if true, existing settings will be replaced rather than updated. Defaults to false. If false, existing settings will be merged with the new settings passed to this function.Optional

Returns: Promise<any> Will be passed a single object argument which contains the saved settings as a JSON object.

load()

Loads the current settings.

Returns: Promise<any> Will be passed a single object argument which contains the saved settings as a JSON object.

onRestore(handler)

Registers a function which will be called if/when settings on the device have been updated from the cloud.

Param Type Details
handler Function

callback function to invoke when device settings have been updated from the cloud.

enableDebug()

Outputs verbose log messages from the native plugin components to the JS console.

Returns: Promise<void>

API

Native

General