![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
cordova-plugin-cloud-settings
Advanced tools
A Cordova plugin for Android & iOS to persist user settings in cloud storage across devices and installs.
A Cordova plugin for Android & iOS to persist user settings in cloud storage across devices and installs.
Table of Contents
This plugin provides a mechanism to store key/value app settings in the form of a JSON structure which will persist 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.
Key features:
Note:
The plugin uses Android's Data Backup service to store settings in a file.
The plugin uses iCloud to store the settings, specifically the NSUbiquitousKeyValueStore class to store settings in a native K/V store
Note:
The plugin is published to npm as cordova-plugin-cloud-settings.
cordova plugin add cordova-plugin-cloud-settings
A typical lifecycle is as follows:
exists()
, sees it has no existing settingssave()
to backup settings to cloudexists()
, sees it has existing settingsload()
to access existing settingsThe plugin's JS API is under the global namespace cordova.plugin.cloudsettings
.
exists()
cordova.plugin.cloudsettings.exists(successCallback);
Indicates if any stored cloud settings currently exist for the current user.
cordova.plugin.cloudsettings.exists(function(exists){
if(exists){
console.log("Saved settings exist for the current user");
}else{
console.log("Saved settings do not exist for the current user");
}
});
save()
cordova.plugin.cloudsettings.save(settings, [successCallback], [errorCallback], [overwrite]);
Saves the settings to cloud backup.
Notes:
var settings = {
user: {
id: 1678,
name: 'Fred',
preferences: {
mute: true,
locale: 'en_GB'
}
}
}
cordova.plugin.cloudsettings.save(settings, function(savedSettings){
console.log("Settings successfully saved at " + (new Date(savedSettings.timestamp)).toISOString());
}, function(error){
console.error("Failed to save settings: " + error);
}, false);
load()
cordova.plugin.cloudsettings.load(successCallback, [errorCallback]);
Loads the current settings.
Note: the settings are loaded locally off disk rather than directly from cloud backup so are not guaranteed to be the latest settings in cloud backup. If you require conflict resolution of local vs cloud settings, you should save a timestamp when loading/saving your settings and use this to resolve any conflicts.
cordova.plugin.cloudsettings.load(function(settings){
console.log("Successfully loaded settings: " + console.log(JSON.stringify(settings)));
}, function(error){
console.error("Failed to load settings: " + error);
});
onRestore()
cordova.plugin.cloudsettings.onRestore(successCallback);
Registers a function which will be called if/when settings on the device have been updated from the cloud.
The purpose of this is to notify your app if current settings have changed due to being updated from the cloud while your app is running. This may occur, for example, if the user has two devices with your app installed; changing settings on one device will cause them to be synched to the other device.
When you call save()
, a timestamp
key is added to the stored settings object which indicates when the settings were saved.
If necessary, this can be used for conflict resolution.
cordova.plugin.cloudsettings.onRestore(function(){
console.log("Settings have been updated from the cloud");
});
enableDebug()
cordova.plugin.cloudsettings.enableDebug(successCallback);
Outputs verbose log messages from the native plugin components to the JS console.
cordova.plugin.cloudsettings.enableDebug(function(){
console.log("Debug mode enabled");
});
To test backup of settings you need to manually invoke the backup manager (as instructed in the Android documentation) to force backing up of the updated values:
First make sure the backup manager is enabled and setup for verbose logging:
$ adb shell bmgr enabled
$ adb shell setprop log.tag.GmsBackupTransport VERBOSE
$ adb shell setprop log.tag.BackupXmlParserLogging VERBOSE
The method of testing the backup then depends on the version of Android running of the target device:
Run the following command to perform a backup:
$ adb shell bmgr backupnow <APP_PACKAGE_ID>
$ adb shell bmgr backup @pm@ && adb shell bmgr run
adb logcat
for the following output: I/BackupManagerService: Backup pass finished.
$ adb shell bmgr fullbackup <APP_PACKAGE_ID>
To manually initiate a restore, run the following command:
$ adb shell bmgr restore <TOKEN> <APP_PACKAGE_ID>
adb shell dumpsys backup
.Ancestral:
and Current:
io.cordova.plugin.cloudsettings.test
: $ adb shell dumpsys backup | grep -P '^\S+\: | \: io\.cordova\.plugin\.cloudsettings\.test'
You also can test automatic restore for your app by uninstalling and reinstalling your app either with adb or through the Google Play Store app.
To wipe the backup data for your app:
$ adb shell bmgr list transports
# note the one with an * next to it, it is the transport protocol for your backup
$ adb shell bmgr wipe [* transport-protocol] <APP_PACKAGE_ID>
iCloud backups happen periodically, hence saving data via the plugin will write it to disk, but it may not be synced to iCloud immediately.
To force an iCloud backup immediately (on iOS 11):
To test restoring, uninstall then re-install the app to sync the data back from iCloud.
You can also install the app on 2 iOS devices. Saving data on one should trigger an call to the onRestore()
callback on the other.
An example project illustrating/validating use of this plugin can be found here: https://github.com/dpa99c/cordova-plugin-cloud-settings-test
Major code contributors:
Based on the plugins:
The MIT License
Copyright (c) 2018-21, Dave Alden (Working Edge Ltd.)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
A Cordova plugin for Android & iOS to persist user settings in cloud storage across devices and installs.
The npm package cordova-plugin-cloud-settings receives a total of 408 weekly downloads. As such, cordova-plugin-cloud-settings popularity was classified as not popular.
We found that cordova-plugin-cloud-settings demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.