Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ repositories {
}

dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+'
implementation 'com.tencent:mmkv-static:1.2.10'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public void setItem(String key, String value, Promise promise) {
MMKV kv = MMKV.defaultMMKV();
kv.encode(key, value);
promise.resolve(value);
} catch (Error e) {
promise.reject("Error", "Unable to setItem");
} catch (Exception e) {
} catch (Error | Exception e) {
promise.reject("Error", "Unable to setItem");
}
}
Expand All @@ -44,9 +42,7 @@ public void getItem(String key, Promise promise) {
try {
MMKV kv = MMKV.defaultMMKV();
promise.resolve(kv.decodeString(key));
} catch (Error e) {
promise.reject("Error", "Unable to getItem");
} catch (Exception e) {
} catch (Error | Exception e) {
promise.reject("Error", "Unable to getItem");
}
}
Expand All @@ -57,9 +53,7 @@ public void removeItem(String key, Promise promise) {
MMKV kv = MMKV.defaultMMKV();
kv.removeValueForKey(key);
promise.resolve(key);
} catch (Error e) {
promise.reject("Error", "Unable to removeItem");
} catch (Exception e) {
} catch (Error | Exception e) {
promise.reject("Error", "Unable to removeItem");
}
}
Expand All @@ -70,9 +64,7 @@ public void clearStore(Promise promise) {
MMKV kv = MMKV.defaultMMKV();
kv.clearAll();
promise.resolve("Done");
} catch (Error e) {
promise.reject("Error", "Unable to removeItem");
} catch (Exception e) {
} catch (Error | Exception e) {
promise.reject("Error", "Unable to removeItem");
}
}
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {NativeModules} from 'react-native';
import { NativeModules, Platform } from 'react-native';

const {RNFastStorage} = NativeModules;
const { RNFastStorage } = NativeModules;

if (RNFastStorage.setupLibrary) RNFastStorage.setupLibrary();
if (Platform.OS === 'ios' && RNFastStorage.setupLibrary) RNFastStorage.setupLibrary();

export default {
...RNFastStorage,
Expand Down