23
votes

I have a background service I wrote in native (Java/ObjectiveC) that needs to access data from AsyncStorage in react native. I would like to know if there is an easy way to get this value directly from the native code instead of having to pass it manually through a bridge method.

Since this is a background service that runs even if the app is not running (in Android), it can not call the Javascript code when it needs this data. I could work around it (by setting it in native at the same time I set it in AsyncStorage) but it would be a lot more work.

2
Any news about this?Pablo

2 Answers

1
votes

If you meant this one: https://reactnative.dev/docs/asyncstorage then, it's deprecated. I recommended react-native-default-preference: https://github.com/kevinresol/react-native-default-preference

On Android, it used SharedPreference, so if you use the same preference name. You should able to read it on Android native code

0
votes

You are going to need to configure the react-native bridge. Here is a good link that should help you understand and configure the bridge.