Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattiamalonni/cordova-ios-plugin-userdefaults
Cordova plugin for App Groups to read and write UserDefaults
https://github.com/mattiamalonni/cordova-ios-plugin-userdefaults
app-groups cordova cordova-ios cordova-ios-plugin cordova-plugin nsuserdefaults userdefaults
Last synced: 8 days ago
JSON representation
Cordova plugin for App Groups to read and write UserDefaults
- Host: GitHub
- URL: https://github.com/mattiamalonni/cordova-ios-plugin-userdefaults
- Owner: mattiamalonni
- License: mit
- Created: 2020-06-05T15:31:36.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-08T07:54:16.000Z (over 4 years ago)
- Last Synced: 2024-11-03T09:33:53.193Z (12 days ago)
- Topics: app-groups, cordova, cordova-ios, cordova-ios-plugin, cordova-plugin, nsuserdefaults, userdefaults
- Language: Objective-C
- Homepage:
- Size: 4.88 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cordova NSUserDefaults Plugin for App Groups
## Description
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.
## Install
```bash
cordova plugin add cordova-ios-plugin-userdefaults
```## Sample Code
The Plugin is only for iOS.
### Save in UserDefaults
```javascript
var options = { key: "foo", value: "bar", suite: "group.com.example" };window.UserDefaults.save(
options,
() => console.log("success"),
() => console.log("error")
);
```### Load from UserDefaults
```javascript
var options = { key: "foo", suite: "group.com.example" };
window.UserDefaults.load(
options,
(data) => console.log(data),
(error) => cosnole.log(error)
);
```