This plugin is used to save and load data to the app groups. It is used to share data between App and Share Extension.
npm install cordova-ios-plugin-userdefaultsIf 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.
``bash`
cordova plugin add cordova-ios-plugin-userdefaults
The Plugin is only for iOS.
`javascript
var options = { key: "foo", value: "bar", suite: "group.com.example" };
window.UserDefaults.save(
options,
() => console.log("success"),
() => console.log("error")
);
`
`javascript``
var options = { key: "foo", suite: "group.com.example" };
window.UserDefaults.load(
options,
(data) => console.log(data),
(error) => cosnole.log(error)
);