Async-storage doesn't work on tvOS
See original GitHub issueCurrent 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: https://github.com/react-native-community/async-storage/commit/4e49db6308882515a284a183c8e9daf5a50b33ef#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.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
What storage options exist for React Native apps on tvOS?
I have a React Native app built for tvOS that uses redux-persist , however, I see the following message in the console every...
Read more >React Native vs Swift: Which One to Use for an iOS Mobile App?
Find out whether React Native or Swift is the perfect technology for building your iOS app. What if it's more cost-effective to use...
Read more >React Native — Apptimize documentation
If you develop your mobile and/or OTT apps using React Native, our React Native SDK allows you to run experiments and manage feature...
Read more >Building For Apple TV React Native官方教程 _w3cschool
General support for tvOS: Apple TV specific changes in native code are all wrapped by the TARGET_OS_TV define. These include changes to suppress...
Read more >React Native Client SDK - Statsig Docs
To work with the SDK, you will need a Statsig account. If you don't yet ... npm install @react-native-async-storage/async-storage react-native-device-info ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@olafurnsig
Temp fix would be to locally move this conditional check, few lines below. I’ll try to test and send PR this week
So to persist, say some authentication token, I would need to save it manually in DefaultPreferences, since AsyncStorage uses the NSCacheDirectory that can be purged at any given moment?