Settings
Settings serves as a wrapper for NSUserDefaults, a persistent key-value store available only on iOS.
Example
Reference
Methods
clearWatch()
tsx
staticclearWatch(watchId:number);
watchId is the number returned by watchKeys() when the subscription was originally configured.
get()
tsx
staticget(key:string):any;
Get the current value for a given key in NSUserDefaults.
set()
tsx
staticset(settings:Record<string,any>);
Set one or more values in NSUserDefaults.
watchKeys()
tsx
staticwatchKeys(keys:string| array<string>,callback:()=>void):number;
Subscribe to be notified when the value for any of the keys specified by the keys parameter has been changed in NSUserDefaults. Returns a watchId number that may be used with clearWatch() to unsubscribe.
Note:
watchKeys()by design ignores internalset()calls and fires callback only on changes preformed outside of React Native code.