From 158c60652ebac6b138f96f942650459dbee39f78 Mon Sep 17 00:00:00 2001 From: Krzysztof Borowy Date: Wed, 30 Sep 2020 20:22:23 +0200 Subject: [PATCH 1/2] fix: bring back tv os support --- ios/RNCAsyncStorage.m | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ios/RNCAsyncStorage.m b/ios/RNCAsyncStorage.m index 2d72ac76..c5564313 100644 --- a/ios/RNCAsyncStorage.m +++ b/ios/RNCAsyncStorage.m @@ -94,10 +94,19 @@ static void RCTAppendError(NSDictionary *error, NSMutableArray * } static NSString *RCTCreateStorageDirectoryPath(NSString *storageDir) { - // We should use the "Application Support/[bundleID]" folder for persistent data storage that's hidden from users - NSString *storageDirectoryPath = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES).firstObject; - storageDirectoryPath = [storageDirectoryPath stringByAppendingPathComponent:[[NSBundle mainBundle] bundleIdentifier]]; // Per Apple's docs, all app content in Application Support must be within a subdirectory of the app's bundle identifier - storageDirectoryPath = [storageDirectoryPath stringByAppendingPathComponent:storageDir]; + NSString *storageDirectoryPath = @""; + + #if TARGET_OS_TV + storageDirectoryPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject; + storageDirectoryPath = [storageDirectoryPath stringByAppendingPathComponent:storageDir]; + #else + storageDirectoryPath = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES).firstObject; + // We should use the "Application Support/[bundleID]" folder for persistent data storage that's hidden from users + storageDirectoryPath = [storageDirectoryPath stringByAppendingPathComponent:[[NSBundle mainBundle] bundleIdentifier]]; // Per Apple's docs, all app content in Application Support must be within a subdirectory of the app's bundle identifier + storageDirectoryPath = [storageDirectoryPath stringByAppendingPathComponent:storageDir]; + #endif + + return storageDirectoryPath; } From be2fee3722a2ce33353ac5d9067518f3ba1657a4 Mon Sep 17 00:00:00 2001 From: Krzysztof Borowy Date: Wed, 7 Oct 2020 11:02:48 +0200 Subject: [PATCH 2/2] chore: remove dup line --- ios/RNCAsyncStorage.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/RNCAsyncStorage.m b/ios/RNCAsyncStorage.m index c5564313..8b20cc2f 100644 --- a/ios/RNCAsyncStorage.m +++ b/ios/RNCAsyncStorage.m @@ -98,15 +98,15 @@ static void RCTAppendError(NSDictionary *error, NSMutableArray * #if TARGET_OS_TV storageDirectoryPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject; - storageDirectoryPath = [storageDirectoryPath stringByAppendingPathComponent:storageDir]; #else storageDirectoryPath = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES).firstObject; // We should use the "Application Support/[bundleID]" folder for persistent data storage that's hidden from users - storageDirectoryPath = [storageDirectoryPath stringByAppendingPathComponent:[[NSBundle mainBundle] bundleIdentifier]]; // Per Apple's docs, all app content in Application Support must be within a subdirectory of the app's bundle identifier - storageDirectoryPath = [storageDirectoryPath stringByAppendingPathComponent:storageDir]; + storageDirectoryPath = [storageDirectoryPath stringByAppendingPathComponent:[[NSBundle mainBundle] bundleIdentifier]]; #endif - + // Per Apple's docs, all app content in Application Support must be within a subdirectory of the app's bundle identifier + storageDirectoryPath = [storageDirectoryPath stringByAppendingPathComponent:storageDir]; + return storageDirectoryPath; }