Skip to content

fix: tvOS support #451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 7, 2020
Merged
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
15 changes: 12 additions & 3 deletions ios/RNCAsyncStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,19 @@ static void RCTAppendError(NSDictionary *error, NSMutableArray<NSDictionary *> *
}

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
NSString *storageDirectoryPath = @"";

#if TARGET_OS_TV
storageDirectoryPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject;
#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]];
#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;
}

Expand Down