Files
flipper/docs/shared-preferences-plugin.md
Marc Terns c7ad49a9eb Integrating NSUserDefaults plugin to iOS (#291)
Summary:
I have a few details left, but its almost done. This PR addresses #145

- The NSUserDefaults plugin uses the SharedPreferences Desktop Part since we can reuse all of it.
- The NSUserDefaults plugin uses swizzling in order to be notified of what specific event changed at runtime.
- Added Test harness in both Sample Swift and Sample apps for iOS in order to test the plugin.
- Updated the documentation in `docs/shared-preferences-plugin.md` and` README.md`

I am open to suggestions since the desktop sharedPreferences version doesn't support deletion of preferences. Most likely I would have to modify the UI, and for that matter, I might as well build a user defaults desktop version

I wanted to add xiphirx in this MR since he developed the shared preferences plugin for Android and Desktop. I don't see a way to remove preferences from the flipper desktop app so I was wondering if you would be OK with me adding that.
Pull Request resolved: https://github.com/facebook/flipper/pull/291

Reviewed By: passy

Differential Revision: D10334685

Pulled By: priteshrnandgaonkar

fbshipit-source-id: d798c01a46df7ddecf713924799f046b560ea922
2018-10-12 04:09:29 -07:00

44 lines
1.1 KiB
Markdown

---
id: shared-preferences-plugin
title: Shared Preferences
---
Easily inspect and modify the data contained within your app's shared preferences.
![Shared Preferences Plugin](/docs/assets/shared-preferences.png)
## Setup
This plugin is available for both Android and iOS.
### Android
```java
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
client.addPlugin(
new SharedPreferencesFlipperPlugin(context, "my_shared_preference_file"));
```
### iOS
#### Swift
```swift
import FlipperKit
client?.add(FKUserDefaultsPlugin.init(suiteName: "your_suitename"))
```
#### Objective-c
```objc
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:@"your_suitename"]];
```
## Usage
All changes to the given shared preference file will automatically appear in Flipper. You may also edit the values in Flipper and have them synced to your device. This can be done by clicking on the value of the specific key you wish to edit, editing the value and then pressing enter.