By: Protonet GmbH
Authors: Joschka Schulz
Use the Cordova CLI and type in the following command:
cordova plugin add https://github.com/protonet/cordova-plugin-nsuserdefaults-for-app-groups.git
If you like to share some variables between your main app and an share extension, you need to save your variables in a NSUserDefaults container. The NSUserData container can be shared between your both apps and hold all the data you want to transfer.
Please make sure you add the App Groups in the XCode Project for sharing the container between apps.
The Plugin is only for iOS.
var options = {
key: "foo",
value: "bar",
suite: "group.cats.catsAreAwesome"};
window.AppGroupsUserDefaults.save(options,
function() {
// success
}, function() {
// failed
});
var options = {
key: "foo",
suite: "group.cats.catsAreAwesome"};
window.AppGroupsUserDefaults.load(options,
function(result) {
// success
console.log("Result:", result)
}, function() {
// failed
});