Closed
Description
Current behavior
Using the lib on tvOS throws "permission denied" error.
Expected behavior
It is possible to use the lib to store data on tvOS.
Repro steps
Just use the library so that it tries to create directory for its files, e.g.:
AsyncStorage.getAllKeys()
.then(keys => AsyncStorage.multiRemove(keys))
.catch(error => console.error('Storage clean failed:', error));
Environment
- Async Storage version: 1.11.0
- React-Native version: 0.61.5
- Platform tested: tvOS 13.4.8 device - could not reproduce in simulator
- Logs/Error that are relevant:
[Error: Failed to create storage directory.Error Domain=NSCocoaErrorDomain Code=513 "You don't have permission to save the file "RCTAsyncLocalStorage_V1" in the folder "com.org.example"." UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/0E076B5B-F577-4D0B-A4E4-58FF3EDF7B5A/Library/Application Support/com.org.example/RCTAsyncLocalStorage_V1, NSUnderlyingError=0x28205dfe0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}]
I think the regression is caused by this change: 4e49db6#diff-54c57f4041d9a698ab027d21344b6e63R98
According to https://developer.apple.com/library/archive/documentation/General/Conceptual/AppleTV_PG/index.html#//apple_ref/doc/uid/TP40015241 section Local Storage for Your App Is Limited - on tvOS data should be stored either in NSUserDefaults
(which is limited to 500KB on tvOS) or in NSCachesDirectory
. I guess async-storage should use the latter.