question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Async-storage doesn't work on tvOS

See original GitHub issue

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: 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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
krizzucommented, Aug 24, 2020

@olafurnsig

Temp fix would be to locally move this conditional check, few lines below. I’ll try to test and send PR this week

0reactions
olafurnsigcommented, Oct 9, 2020

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found