Skip to content

Commit 8e6c8cb

Browse files
author
Krzysztof
authored
fix: tvOS support (#451)
1 parent 0ba7726 commit 8e6c8cb

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

ios/RNCAsyncStorage.m

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,19 @@ static void RCTAppendError(NSDictionary *error, NSMutableArray<NSDictionary *> *
9494
}
9595

9696
static NSString *RCTCreateStorageDirectoryPath(NSString *storageDir) {
97-
// We should use the "Application Support/[bundleID]" folder for persistent data storage that's hidden from users
98-
NSString *storageDirectoryPath = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES).firstObject;
99-
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
97+
NSString *storageDirectoryPath = @"";
98+
99+
#if TARGET_OS_TV
100+
storageDirectoryPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject;
101+
#else
102+
storageDirectoryPath = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES).firstObject;
103+
// We should use the "Application Support/[bundleID]" folder for persistent data storage that's hidden from users
104+
storageDirectoryPath = [storageDirectoryPath stringByAppendingPathComponent:[[NSBundle mainBundle] bundleIdentifier]];
105+
#endif
106+
107+
// Per Apple's docs, all app content in Application Support must be within a subdirectory of the app's bundle identifier
100108
storageDirectoryPath = [storageDirectoryPath stringByAppendingPathComponent:storageDir];
109+
101110
return storageDirectoryPath;
102111
}
103112

0 commit comments

Comments
 (0)