├── .gitignore ├── LICENSE ├── README.md ├── RNUserDefaults.podspec ├── android ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── chat │ └── rocket │ └── userdefaults │ ├── RNUserDefaultsModule.java │ └── RNUserDefaultsPackage.java ├── index.js ├── ios ├── RNUserDefaults.h ├── RNUserDefaults.m └── RNUserDefaults.xcodeproj │ └── project.pbxproj └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Djorkaeff Alexandre 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # rn-user-defaults 3 | 4 | Use `UserDefaults` (iOS) and `SharedPreferences` (AndroidOS) with React Native, this can help you to share credentials between apps or between app and extensions on iOS. 5 | 6 | ## Getting started 7 | 8 | `$ npm install rn-user-defaults --save` 9 | 10 | or 11 | 12 | `$ yarn add rn-user-defaults` 13 | 14 | If you are using `React Native 0.60.+` go to the folder **your-project/ios** and run `pod install`, and you're done. 15 | 16 | If not, use one of the following method to link. 17 | 18 | ### Mostly automatic with `react-native link` 19 | 20 | If you are using `React Native <= 0.59.X`, link the native project: 21 | 22 | `$ react-native link rn-user-defaults` 23 | 24 | ### Manual installation 25 | 26 | If you are using `React Native <= 0.59.X` and `react-native link` don't work for you: 27 | 28 | #### iOS 29 | 30 | 1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]` 31 | 2. Go to `node_modules` ➜ `rn-user-defaults` and add `RNUserDefaults.xcodeproj` 32 | 3. In XCode, in the project navigator, select your project. Add `libRNUserDefaults.a` to your project's `Build Phases` ➜ `Link Binary With Libraries` 33 | 4. Run your project (`Cmd+R`)< 34 | 35 | #### Android 36 | 37 | - Edit `android/settings.gradle` and add the following 38 | 39 | ```gradle 40 | include ':app', ':rn-user-defaults' 41 | 42 | project(':rn-user-defaults').projectDir = new File(rootProject.projectDir, '../node_modules/rn-user-defaults/android') 43 | ``` 44 | 45 | - Edit `android/app/build.gradle` and add the following line before the react section in dependencies 46 | 47 | ```gradle 48 | dependencies { 49 | ... 50 | implementation project(':rn-user-defaults') 51 | implementation "com.facebook.react:react-native:+" 52 | } 53 | ``` 54 | 55 | - Add these lines to `MainApplication.java` 56 | 57 | ```java 58 | ... 59 | import chat.rocket.userdefaults; 60 | ... 61 | @Override 62 | protected List getPackages() { 63 | @SuppressWarnings("UnnecessaryLocalVariable") 64 | List packages = new PackageList(this).getPackages(); 65 | ... 66 | packages.add(new RNUserDefaultsPackage()); 67 | return packages; 68 | } 69 | ``` 70 | 71 | ## Usage 72 | 73 | ```js 74 | import RNUserDefaults from 'rn-user-defaults'; 75 | 76 | RNUserDefaults.set('key', 'value').then(function() {console.log('done')}); // done 77 | RNUserDefaults.get('key').then(function(value) {console.log(value)}); // value 78 | RNUserDefaults.setObjectForKey('objKey', { dog: 1 }).then(function() {console.log('done')}); // done 79 | RNUserDefaults.objectForKey('objKey').then(function(value) {console.log(value)}); // { dog: 1 } 80 | ``` 81 | 82 | ## Static methods 83 | 84 | Now you can use static methods to access current SharedPreferences or UserDefaults classes on native modules. 85 | 86 | #### Android 87 | 88 | ```java 89 | import android.content.SharedPreferences; 90 | import chat.rocket.userdefaults.RNUserDefaultsModule; 91 | 92 | SharedPreferences sharedPreferences = RNUserDefaultsModule.getPreferences(); 93 | String exampleString = sharedPreferences.getString("STRING_KEY", ""); 94 | 95 | SharedPreferences sharedPreferences1 = RNUserDefaultsModule.getPreferences(reactApplicationContext); 96 | String exampleString1 = sharedPreferences1.getString("STRING_KEY", ""); 97 | 98 | SharedPreferences sharedPreferences2 = RNUserDefaultsModule.getPreferences(reactApplicationContext, contextName, preferencesName); 99 | String exampleString2 = sharedPreferences2.getString("STRING_KEY", ""); 100 | ``` 101 | 102 | #### iOS 103 | ```objective-c 104 | #import "RNUserDefaults.h" 105 | 106 | NSDictionary *exampleObject = [[RNUserDefaults getDefaultUser] objectForKey:@"OBJECT_KEY"]; 107 | ``` 108 | 109 | ### Set a AppGroup on iOS 110 | Add the follow code to your Info.plist 111 | ``` 112 | AppGroup 113 | your.group.name 114 | ``` 115 | 116 | ## API 117 | 118 | ```haxe 119 | function get(key:String):Promise; 120 | function set(key:String, value:String):Promise; 121 | function setObjectForKey(key:String, value:Object):Promise; 122 | function objectForKey(key:String):Promise; 123 | function clear(key:String):Promise; 124 | function clearAll():Promise; 125 | 126 | /** 127 | Android = getReactApplicationContext().getSharedPreferences(name, Context.MODE_PRIVATE); 128 | **/ 129 | function setName(name:String):Promise; 130 | 131 | /** 132 | You can set a context to you sharedPreferences (Android) 133 | **/ 134 | function setPackageContext(context:String):Promise; 135 | ``` 136 | 137 | ## License 138 | 139 | ``` 140 | MIT License 141 | 142 | Copyright (c) 2019 Djorkaeff Alexandre 143 | ``` 144 | 145 | See the full [licence file](https://github.com/RocketChat/rn-user-defaults/blob/master/LICENSE). 146 | -------------------------------------------------------------------------------- /RNUserDefaults.podspec: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = "RNUserDefaults" 7 | s.version = package['version'] 8 | s.summary = package['description'] 9 | s.description = package['description'] 10 | s.license = package['license'] 11 | s.author = package['author'] 12 | s.homepage = package['homepage'] 13 | s.source = { :git => 'https://github.com/RocketChat/rn-user-defaults.git' } 14 | 15 | s.requires_arc = true 16 | s.platform = :ios, '7.0' 17 | 18 | s.preserve_paths = 'README.md', 'package.json', 'index.js' 19 | s.source_files = 'iOS/*.{h,m}' 20 | 21 | s.dependency 'React' 22 | end 23 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | 6 | dependencies { 7 | classpath 'com.android.tools.build:gradle:1.1.3' 8 | } 9 | } 10 | 11 | apply plugin: 'com.android.library' 12 | 13 | android { 14 | compileSdkVersion 23 15 | buildToolsVersion "23.0.1" 16 | 17 | defaultConfig { 18 | minSdkVersion 16 19 | targetSdkVersion 22 20 | versionCode 1 21 | versionName "1.0" 22 | } 23 | lintOptions { 24 | abortOnError false 25 | } 26 | } 27 | 28 | repositories { 29 | mavenCentral() 30 | } 31 | 32 | dependencies { 33 | implementation "com.facebook.react:react-native:+" 34 | } 35 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /android/src/main/java/chat/rocket/userdefaults/RNUserDefaultsModule.java: -------------------------------------------------------------------------------- 1 | package chat.rocket.userdefaults; 2 | 3 | import android.util.Log; 4 | import android.content.Context; 5 | import android.content.SharedPreferences; 6 | 7 | import com.facebook.react.bridge.Arguments; 8 | import com.facebook.react.bridge.ReactApplicationContext; 9 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 10 | import com.facebook.react.bridge.ReactMethod; 11 | import com.facebook.react.bridge.Callback; 12 | import com.facebook.react.bridge.Promise; 13 | import com.facebook.react.bridge.ReadableMap; 14 | import com.facebook.react.bridge.ReadableArray; 15 | import com.facebook.react.bridge.ReadableMapKeySetIterator; 16 | import com.facebook.react.bridge.WritableArray; 17 | import com.facebook.react.bridge.WritableMap; 18 | 19 | import java.util.Map; 20 | 21 | public class RNUserDefaultsModule extends ReactContextBaseJavaModule { 22 | private static String preferencesName = "react-native"; 23 | private static String contextName = null; 24 | 25 | private static ReactApplicationContext reactContext; 26 | 27 | public RNUserDefaultsModule(ReactApplicationContext reactContext) { 28 | super(reactContext); 29 | this.reactContext = reactContext; 30 | } 31 | 32 | @Override 33 | public String getName() { 34 | return "RNUserDefaults"; 35 | } 36 | 37 | @ReactMethod 38 | public void get(String key, Promise promise) { 39 | promise.resolve(getPreferences().getString(key, null)); 40 | } 41 | 42 | @ReactMethod 43 | public void set(String key, String value, Promise promise) { 44 | getEditor().putString(key, value).commit(); 45 | promise.resolve(null); 46 | } 47 | 48 | @ReactMethod 49 | public void clear(String key, Promise promise) { 50 | getEditor().remove(key).commit(); 51 | promise.resolve(null); 52 | } 53 | 54 | @ReactMethod 55 | public void clearAll(Promise promise) { 56 | SharedPreferences.Editor editor = getEditor(); 57 | Map allEntries = getPreferences().getAll(); 58 | for (Map.Entry entry : allEntries.entrySet()) { 59 | editor.remove(entry.getKey()); 60 | } 61 | editor.commit(); 62 | promise.resolve(null); 63 | } 64 | 65 | @ReactMethod 66 | public void setName(String preferencesName, Promise promise) { 67 | this.preferencesName = preferencesName; 68 | promise.resolve(null); 69 | } 70 | 71 | @ReactMethod 72 | public void setPackageContext(String contextName, Promise promise) { 73 | this.contextName = contextName; 74 | promise.resolve(null); 75 | } 76 | 77 | @ReactMethod 78 | public void getName(Promise promise) { 79 | promise.resolve(preferencesName); 80 | } 81 | 82 | public static SharedPreferences getPreferences() { 83 | if (contextName != null) { 84 | try { 85 | return reactContext.createPackageContext(contextName, Context.CONTEXT_INCLUDE_CODE) 86 | .getSharedPreferences(preferencesName, Context.MODE_PRIVATE); 87 | } catch (Exception e) { 88 | String error = e.getMessage(); 89 | Log.d("RNUserDefaults", error); 90 | return reactContext.getSharedPreferences(preferencesName, Context.MODE_PRIVATE); 91 | } 92 | } 93 | return reactContext.getSharedPreferences(preferencesName, Context.MODE_PRIVATE); 94 | } 95 | 96 | public static SharedPreferences getPreferences(ReactApplicationContext reactApplicationContext) { 97 | return reactApplicationContext.getSharedPreferences(preferencesName, Context.MODE_PRIVATE); 98 | } 99 | 100 | public static SharedPreferences getPreferences(ReactApplicationContext reactApplicationContext, String preferencesName, String contextName) { 101 | if (contextName != null) { 102 | try { 103 | return reactApplicationContext.createPackageContext(contextName, Context.CONTEXT_INCLUDE_CODE) 104 | .getSharedPreferences(preferencesName, Context.MODE_PRIVATE); 105 | } catch (Exception e) { 106 | String error = e.getMessage(); 107 | Log.d("RNUserDefaults", error); 108 | return reactApplicationContext.getSharedPreferences(preferencesName, Context.MODE_PRIVATE); 109 | } 110 | } 111 | return reactApplicationContext.getSharedPreferences(preferencesName, Context.MODE_PRIVATE); 112 | } 113 | 114 | private SharedPreferences.Editor getEditor() { 115 | return getPreferences().edit(); 116 | } 117 | } -------------------------------------------------------------------------------- /android/src/main/java/chat/rocket/userdefaults/RNUserDefaultsPackage.java: -------------------------------------------------------------------------------- 1 | package chat.rocket.userdefaults; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.bridge.NativeModule; 9 | import com.facebook.react.bridge.ReactApplicationContext; 10 | import com.facebook.react.uimanager.ViewManager; 11 | import com.facebook.react.bridge.JavaScriptModule; 12 | 13 | public class RNUserDefaultsPackage implements ReactPackage { 14 | @Override 15 | public List createNativeModules(ReactApplicationContext reactContext) { 16 | return Arrays.asList(new RNUserDefaultsModule(reactContext)); 17 | } 18 | 19 | public List> createJSModules() { 20 | return Collections.emptyList(); 21 | } 22 | 23 | @Override 24 | public List createViewManagers(ReactApplicationContext reactContext) { 25 | return Collections.emptyList(); 26 | } 27 | } -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import { NativeModules, Platform } from 'react-native'; 2 | 3 | const { RNUserDefaults: NativeUserDefaults } = NativeModules; 4 | 5 | const RNUserDefaults = Platform.select({ 6 | ios: { 7 | ...NativeUserDefaults, 8 | setPackageContext: () => Promise.resolve(), 9 | setName: () => Promise.resolve() 10 | }, 11 | android: { 12 | ...NativeUserDefaults, 13 | setObjectForKey: (key, value) => { 14 | const valueStringify = JSON.stringify(value); 15 | return NativeUserDefaults.set(key, valueStringify); 16 | }, 17 | objectForKey: async(key) => { 18 | try { 19 | const value = await NativeUserDefaults.get(key); 20 | return JSON.parse(value); 21 | } catch { 22 | return null; 23 | } 24 | } 25 | } 26 | }); 27 | 28 | export default RNUserDefaults; 29 | -------------------------------------------------------------------------------- /ios/RNUserDefaults.h: -------------------------------------------------------------------------------- 1 | 2 | // import RCTBridgeModule 3 | #if __has_include() 4 | #import 5 | #elif __has_include("RCTBridgeModule.h") 6 | #import "RCTBridgeModule.h" 7 | #else 8 | #import "React/RCTBridgeModule.h" // Required when used as a Pod in a Swift project 9 | #endif 10 | 11 | @interface RNUserDefaults : NSObject 12 | + (NSUserDefaults *)getDefaultUser; 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /ios/RNUserDefaults.m: -------------------------------------------------------------------------------- 1 | #import "RNUserDefaults.h" 2 | 3 | @implementation RNUserDefaults 4 | 5 | - (dispatch_queue_t)methodQueue 6 | { 7 | return dispatch_get_main_queue(); 8 | } 9 | 10 | + (NSUserDefaults *)getDefaultUser { 11 | NSString *suiteName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppGroup"]; 12 | if(suiteName == nil){ 13 | return [NSUserDefaults standardUserDefaults]; 14 | } else { 15 | return [[NSUserDefaults alloc] initWithSuiteName:suiteName]; 16 | } 17 | } 18 | 19 | RCT_EXPORT_MODULE() 20 | 21 | RCT_EXPORT_METHOD(setObjectForKey:(NSString *)key object:object 22 | resolve:(RCTPromiseResolveBlock)resolve 23 | reject:(__unused RCTPromiseRejectBlock)reject) { 24 | 25 | [[RNUserDefaults getDefaultUser] setObject:object forKey:key]; 26 | 27 | resolve([NSNull null]); 28 | } 29 | 30 | RCT_EXPORT_METHOD(objectForKey:(NSString *)key 31 | resolve:(RCTPromiseResolveBlock)resolve 32 | reject:(__unused RCTPromiseRejectBlock)reject) { 33 | 34 | resolve([[RNUserDefaults getDefaultUser] objectForKey:key]); 35 | } 36 | 37 | RCT_EXPORT_METHOD(get:(NSString *)key 38 | resolve:(RCTPromiseResolveBlock)resolve 39 | reject:(__unused RCTPromiseRejectBlock)reject) 40 | { 41 | resolve([[RNUserDefaults getDefaultUser] stringForKey:key]); 42 | } 43 | 44 | RCT_EXPORT_METHOD(set:(NSString *)key value:(NSString *)value 45 | resolve:(RCTPromiseResolveBlock)resolve 46 | reject:(__unused RCTPromiseRejectBlock)reject) 47 | { 48 | [[RNUserDefaults getDefaultUser] setObject:value forKey:key]; 49 | resolve([NSNull null]); 50 | } 51 | 52 | RCT_EXPORT_METHOD(clear:(NSString *)key 53 | resolve:(RCTPromiseResolveBlock)resolve 54 | reject:(__unused RCTPromiseRejectBlock)reject) 55 | { 56 | [[RNUserDefaults getDefaultUser] removeObjectForKey:key]; 57 | resolve([NSNull null]); 58 | } 59 | 60 | RCT_EXPORT_METHOD(clearMultiple:(NSArray *)keys 61 | resolve:(RCTPromiseResolveBlock)resolve 62 | reject:(__unused RCTPromiseRejectBlock)reject) 63 | { 64 | for(NSString *key in keys) { 65 | [[RNUserDefaults getDefaultUser] removeObjectForKey:key]; 66 | } 67 | resolve([NSNull null]); 68 | } 69 | 70 | RCT_EXPORT_METHOD(clearAll:(RCTPromiseResolveBlock)resolve 71 | reject:(RCTPromiseRejectBlock)reject) 72 | { 73 | NSArray *keys = [[[RNUserDefaults getDefaultUser] dictionaryRepresentation] allKeys]; 74 | [self clearMultiple:keys resolve:resolve reject:reject]; 75 | } 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /ios/RNUserDefaults.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B3E7B58A1CC2AC0600A0062D /* RNUserDefaults.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNUserDefaults.m */; }; 11 | /* End PBXBuildFile section */ 12 | 13 | /* Begin PBXCopyFilesBuildPhase section */ 14 | 58B511D91A9E6C8500147676 /* CopyFiles */ = { 15 | isa = PBXCopyFilesBuildPhase; 16 | buildActionMask = 2147483647; 17 | dstPath = "include/$(PRODUCT_NAME)"; 18 | dstSubfolderSpec = 16; 19 | files = ( 20 | ); 21 | runOnlyForDeploymentPostprocessing = 0; 22 | }; 23 | /* End PBXCopyFilesBuildPhase section */ 24 | 25 | /* Begin PBXFileReference section */ 26 | 134814201AA4EA6300B7C361 /* libRNUserDefaults.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNUserDefaults.a; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | B3E7B5881CC2AC0600A0062D /* RNUserDefaults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNUserDefaults.h; sourceTree = ""; }; 28 | B3E7B5891CC2AC0600A0062D /* RNUserDefaults.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNUserDefaults.m; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 58B511D81A9E6C8500147676 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 134814211AA4EA7D00B7C361 /* Products */ = { 43 | isa = PBXGroup; 44 | children = ( 45 | 134814201AA4EA6300B7C361 /* libRNUserDefaults.a */, 46 | ); 47 | name = Products; 48 | sourceTree = ""; 49 | }; 50 | 58B511D21A9E6C8500147676 = { 51 | isa = PBXGroup; 52 | children = ( 53 | B3E7B5881CC2AC0600A0062D /* RNUserDefaults.h */, 54 | B3E7B5891CC2AC0600A0062D /* RNUserDefaults.m */, 55 | 134814211AA4EA7D00B7C361 /* Products */, 56 | ); 57 | sourceTree = ""; 58 | }; 59 | /* End PBXGroup section */ 60 | 61 | /* Begin PBXNativeTarget section */ 62 | 58B511DA1A9E6C8500147676 /* RNUserDefaults */ = { 63 | isa = PBXNativeTarget; 64 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNUserDefaults" */; 65 | buildPhases = ( 66 | 58B511D71A9E6C8500147676 /* Sources */, 67 | 58B511D81A9E6C8500147676 /* Frameworks */, 68 | 58B511D91A9E6C8500147676 /* CopyFiles */, 69 | ); 70 | buildRules = ( 71 | ); 72 | dependencies = ( 73 | ); 74 | name = RNUserDefaults; 75 | productName = RCTDataManager; 76 | productReference = 134814201AA4EA6300B7C361 /* libRNUserDefaults.a */; 77 | productType = "com.apple.product-type.library.static"; 78 | }; 79 | /* End PBXNativeTarget section */ 80 | 81 | /* Begin PBXProject section */ 82 | 58B511D31A9E6C8500147676 /* Project object */ = { 83 | isa = PBXProject; 84 | attributes = { 85 | LastUpgradeCheck = 0610; 86 | ORGANIZATIONNAME = Facebook; 87 | TargetAttributes = { 88 | 58B511DA1A9E6C8500147676 = { 89 | CreatedOnToolsVersion = 6.1.1; 90 | }; 91 | }; 92 | }; 93 | buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNUserDefaults" */; 94 | compatibilityVersion = "Xcode 3.2"; 95 | developmentRegion = English; 96 | hasScannedForEncodings = 0; 97 | knownRegions = ( 98 | en, 99 | ); 100 | mainGroup = 58B511D21A9E6C8500147676; 101 | productRefGroup = 58B511D21A9E6C8500147676; 102 | projectDirPath = ""; 103 | projectRoot = ""; 104 | targets = ( 105 | 58B511DA1A9E6C8500147676 /* RNUserDefaults */, 106 | ); 107 | }; 108 | /* End PBXProject section */ 109 | 110 | /* Begin PBXSourcesBuildPhase section */ 111 | 58B511D71A9E6C8500147676 /* Sources */ = { 112 | isa = PBXSourcesBuildPhase; 113 | buildActionMask = 2147483647; 114 | files = ( 115 | B3E7B58A1CC2AC0600A0062D /* RNUserDefaults.m in Sources */, 116 | ); 117 | runOnlyForDeploymentPostprocessing = 0; 118 | }; 119 | /* End PBXSourcesBuildPhase section */ 120 | 121 | /* Begin XCBuildConfiguration section */ 122 | 58B511ED1A9E6C8500147676 /* Debug */ = { 123 | isa = XCBuildConfiguration; 124 | buildSettings = { 125 | ALWAYS_SEARCH_USER_PATHS = NO; 126 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 127 | CLANG_CXX_LIBRARY = "libc++"; 128 | CLANG_ENABLE_MODULES = YES; 129 | CLANG_ENABLE_OBJC_ARC = YES; 130 | CLANG_WARN_BOOL_CONVERSION = YES; 131 | CLANG_WARN_CONSTANT_CONVERSION = YES; 132 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 133 | CLANG_WARN_EMPTY_BODY = YES; 134 | CLANG_WARN_ENUM_CONVERSION = YES; 135 | CLANG_WARN_INT_CONVERSION = YES; 136 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 137 | CLANG_WARN_UNREACHABLE_CODE = YES; 138 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 139 | COPY_PHASE_STRIP = NO; 140 | ENABLE_STRICT_OBJC_MSGSEND = YES; 141 | GCC_C_LANGUAGE_STANDARD = gnu99; 142 | GCC_DYNAMIC_NO_PIC = NO; 143 | GCC_OPTIMIZATION_LEVEL = 0; 144 | GCC_PREPROCESSOR_DEFINITIONS = ( 145 | "DEBUG=1", 146 | "$(inherited)", 147 | ); 148 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 149 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 150 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 151 | GCC_WARN_UNDECLARED_SELECTOR = YES; 152 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 153 | GCC_WARN_UNUSED_FUNCTION = YES; 154 | GCC_WARN_UNUSED_VARIABLE = YES; 155 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 156 | MTL_ENABLE_DEBUG_INFO = YES; 157 | ONLY_ACTIVE_ARCH = YES; 158 | SDKROOT = iphoneos; 159 | }; 160 | name = Debug; 161 | }; 162 | 58B511EE1A9E6C8500147676 /* Release */ = { 163 | isa = XCBuildConfiguration; 164 | buildSettings = { 165 | ALWAYS_SEARCH_USER_PATHS = NO; 166 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 167 | CLANG_CXX_LIBRARY = "libc++"; 168 | CLANG_ENABLE_MODULES = YES; 169 | CLANG_ENABLE_OBJC_ARC = YES; 170 | CLANG_WARN_BOOL_CONVERSION = YES; 171 | CLANG_WARN_CONSTANT_CONVERSION = YES; 172 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 173 | CLANG_WARN_EMPTY_BODY = YES; 174 | CLANG_WARN_ENUM_CONVERSION = YES; 175 | CLANG_WARN_INT_CONVERSION = YES; 176 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 177 | CLANG_WARN_UNREACHABLE_CODE = YES; 178 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 179 | COPY_PHASE_STRIP = YES; 180 | ENABLE_NS_ASSERTIONS = NO; 181 | ENABLE_STRICT_OBJC_MSGSEND = YES; 182 | GCC_C_LANGUAGE_STANDARD = gnu99; 183 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 184 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 185 | GCC_WARN_UNDECLARED_SELECTOR = YES; 186 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 187 | GCC_WARN_UNUSED_FUNCTION = YES; 188 | GCC_WARN_UNUSED_VARIABLE = YES; 189 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 190 | MTL_ENABLE_DEBUG_INFO = NO; 191 | SDKROOT = iphoneos; 192 | VALIDATE_PRODUCT = YES; 193 | }; 194 | name = Release; 195 | }; 196 | 58B511F01A9E6C8500147676 /* Debug */ = { 197 | isa = XCBuildConfiguration; 198 | buildSettings = { 199 | HEADER_SEARCH_PATHS = ( 200 | "$(inherited)", 201 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 202 | "$(SRCROOT)/../../../React/**", 203 | "$(SRCROOT)/../../react-native/React/**", 204 | ); 205 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 206 | OTHER_LDFLAGS = "-ObjC"; 207 | PRODUCT_NAME = RNUserDefaults; 208 | SKIP_INSTALL = YES; 209 | }; 210 | name = Debug; 211 | }; 212 | 58B511F11A9E6C8500147676 /* Release */ = { 213 | isa = XCBuildConfiguration; 214 | buildSettings = { 215 | HEADER_SEARCH_PATHS = ( 216 | "$(inherited)", 217 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 218 | "$(SRCROOT)/../../../React/**", 219 | "$(SRCROOT)/../../react-native/React/**", 220 | ); 221 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 222 | OTHER_LDFLAGS = "-ObjC"; 223 | PRODUCT_NAME = RNUserDefaults; 224 | SKIP_INSTALL = YES; 225 | }; 226 | name = Release; 227 | }; 228 | /* End XCBuildConfiguration section */ 229 | 230 | /* Begin XCConfigurationList section */ 231 | 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNUserDefaults" */ = { 232 | isa = XCConfigurationList; 233 | buildConfigurations = ( 234 | 58B511ED1A9E6C8500147676 /* Debug */, 235 | 58B511EE1A9E6C8500147676 /* Release */, 236 | ); 237 | defaultConfigurationIsVisible = 0; 238 | defaultConfigurationName = Release; 239 | }; 240 | 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNUserDefaults" */ = { 241 | isa = XCConfigurationList; 242 | buildConfigurations = ( 243 | 58B511F01A9E6C8500147676 /* Debug */, 244 | 58B511F11A9E6C8500147676 /* Release */, 245 | ); 246 | defaultConfigurationIsVisible = 0; 247 | defaultConfigurationName = Release; 248 | }; 249 | /* End XCConfigurationList section */ 250 | }; 251 | rootObject = 58B511D31A9E6C8500147676 /* Project object */; 252 | } 253 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rn-user-defaults", 3 | "version": "1.8.1", 4 | "description": "Use `UserDefaults` (iOS) with React Native and `SharedPreferences` on AndroidOS.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [ 10 | "react-native", 11 | "NSUserDefaults", 12 | "user defaults" 13 | ], 14 | "author": "djorkaeffalexandre", 15 | "license": "MIT", 16 | "peerDependencies": { 17 | "react-native": ">=0.47.0" 18 | }, 19 | "homepage": "https://github.com/RocketChat/rn-user-defaults.git" 20 | } 21 | --------------------------------------------------------------------------------