2023-08-17 19:41:20 +00:00
|
|
|
diff --git a/node_modules/react-native-mmkv-storage/ios/MMKVNative.mm b/node_modules/react-native-mmkv-storage/ios/MMKVNative.mm
|
|
|
|
index 9af089d..12ff53b 100644
|
|
|
|
--- a/node_modules/react-native-mmkv-storage/ios/MMKVNative.mm
|
|
|
|
+++ b/node_modules/react-native-mmkv-storage/ios/MMKVNative.mm
|
|
|
|
@@ -37,12 +37,43 @@ - (instancetype)init
|
|
|
|
rPath = rootDir;
|
|
|
|
_secureStorage = [[SecureStorage alloc] init];
|
|
|
|
[MMKV initializeMMKV:rootDir];
|
|
|
|
+ [self addSkipBackupAttributeToDir:rootDir];
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
+- (BOOL)addSkipBackupAttributeToURLAtPath:(NSURL *)url
|
|
|
|
+{
|
|
|
|
+ if (!url) return NO;
|
|
|
|
+ if (![[NSFileManager defaultManager] fileExistsAtPath:url.path]) return NO;
|
|
|
|
+
|
|
|
|
+ NSError *error = nil;
|
|
|
|
+ NSNumber *value = nil;
|
|
|
|
+ BOOL success = [url getResourceValue:&value forKey:NSURLIsExcludedFromBackupKey error:&error];
|
|
|
|
+ if (value.boolValue == YES) {
|
|
|
|
+ NSLog(@"%@ already marked for backup exclusion", [url lastPathComponent]);
|
|
|
|
+ return YES;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ success = [url setResourceValue:[NSNumber numberWithBool:YES]
|
|
|
|
+ forKey:NSURLIsExcludedFromBackupKey error:&error];
|
|
|
|
+ if(!success){
|
|
|
|
+ NSLog(@"Error excluding %@ from backup: %@", [url lastPathComponent], error);
|
|
|
|
+ } else {
|
|
|
|
+ NSLog(@"Succesfully marked %@ for backup exclusion", [url lastPathComponent]);
|
|
|
|
+ }
|
|
|
|
+ return success;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (BOOL) addSkipBackupAttributeToDir:(NSString *)path
|
|
|
|
+{
|
|
|
|
+ if (!path) return NO;
|
|
|
|
+ NSURL *pathUrl = [[NSURL alloc] initFileURLWithPath:path isDirectory:YES];
|
|
|
|
+ return [self addSkipBackupAttributeToURLAtPath:pathUrl];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
MMKV *getInstance(NSString *ID) {
|
|
|
|
if ([[mmkvInstances allKeys] containsObject:ID]) {
|
|
|
|
MMKV *kv = [mmkvInstances objectForKey:ID];
|
2022-08-08 21:02:08 +00:00
|
|
|
diff --git a/node_modules/react-native-mmkv-storage/ios/SecureStorage.m b/node_modules/react-native-mmkv-storage/ios/SecureStorage.m
|
2023-01-18 16:43:26 +00:00
|
|
|
index dbea26b..2483375 100644
|
2022-08-08 21:02:08 +00:00
|
|
|
--- a/node_modules/react-native-mmkv-storage/ios/SecureStorage.m
|
|
|
|
+++ b/node_modules/react-native-mmkv-storage/ios/SecureStorage.m
|
2022-11-21 19:16:53 +00:00
|
|
|
@@ -40,14 +40,14 @@ - (NSString *) getSecureKey:(NSString *)key
|
2022-08-08 21:02:08 +00:00
|
|
|
@try {
|
|
|
|
[self handleAppUninstallation];
|
|
|
|
NSString *value = [self searchKeychainCopyMatching:key];
|
|
|
|
- dispatch_sync(dispatch_get_main_queue(), ^{
|
|
|
|
- int readAttempts = 0;
|
|
|
|
- // See: https://github.com/ammarahm-ed/react-native-mmkv-storage/issues/195
|
|
|
|
- while (![[UIApplication sharedApplication] isProtectedDataAvailable] && readAttempts++ < 100) {
|
|
|
|
- // sleep 25ms before another attempt
|
|
|
|
- usleep(25000);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
+// dispatch_sync(dispatch_get_main_queue(), ^{
|
|
|
|
+// int readAttempts = 0;
|
|
|
|
+// // See: https://github.com/ammarahm-ed/react-native-mmkv-storage/issues/195
|
|
|
|
+// while (![[UIApplication sharedApplication] isProtectedDataAvailable] && readAttempts++ < 100) {
|
|
|
|
+// // sleep 25ms before another attempt
|
|
|
|
+// usleep(25000);
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
if (value == nil) {
|
|
|
|
NSString* errorMessage = @"key does not present";
|
|
|
|
|
2022-11-21 19:16:53 +00:00
|
|
|
@@ -100,6 +100,9 @@ - (void) removeSecureKey:(NSString *)key
|
2022-08-08 21:02:08 +00:00
|
|
|
|
|
|
|
- (NSMutableDictionary *)newSearchDictionary:(NSString *)identifier {
|
|
|
|
NSMutableDictionary *searchDictionary = [[NSMutableDictionary alloc] init];
|
|
|
|
+ // this value is shared by main app and extensions, so, is the best to be used here
|
|
|
|
+ serviceName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppGroup"];
|
|
|
|
+
|
|
|
|
if(serviceName == nil){
|
|
|
|
serviceName = [[NSBundle mainBundle] bundleIdentifier];
|
|
|
|
}
|