react-native-async-storage/async-storage

[iOS] Use app groups path to save storage.

Closed this issue ยท 14 comments

Motivation

When you try to create an iOS Extension (Eg: Share Extension, Watch Extension), if you store info on AsyncStorage you do not have access to this. If you have a method to set suite name to storage path you can use folder of app group and use that.

Description

Create a function like

AsyncStorage.setSuite('group.example')

and after that AsyncStorage use the App Group's path on iOS.

New feature implementation

Can you use code like that to select path to save storage:

NSURL * pathUrl = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier: @"group.example"];

Hi @djorkaeffalexandre ,

Would setting a delegate on Async Storage be helpful in your case? With this, you have access from Native Side to stored data via AS.

This would be extremely useful to have, right now the way I go about this is to create a file that I write using the appGroupId so it I can access it from the native side in the Share Extension, so basically I'm duplicating the data.

By having a way to initialize the AsyncStorage with an appGroup I will no longer need to dup the data.

Perhaps something to consider for v2?

@enahum Yup, definitely. Going to put it on the todo. For now, I'm going to close this one.

thanks.

Hi @krizzu ! Any news on when this might be available? Would love to use this feature!

Actual for me too

I'd like to know a real use case here - As far I as know, RN is not targeting watch extensions yet.

@krizzu access to data in notification extensions, share extensions, etc...

This would be very useful for acessing data in share extensions indeed

+1 on this.

the problem i forsee is that setting an appgroup dynamically might have unintended side-effects. i'd imagine that we would want to set appgroup after hydration of the manifest.json file for data migration on existing apps but we would want to set it before hydration after saving data to the new appgroup.

its a little tricky since async-storage is using a file under the hood.

My question would be if we need to do this dynamically or would setting it once do the trick?
If it's the former, we could have a flag set in Info.plist and use it to change storage to app group path.

Hey, any news about this one? This would be extremely helpful!!

arual5 commented

Hi @krizzu ! :) Any news on when this might be available?
I really need to use this feature since I have been using AS library for a long time and I need to be able to access data in notification extension, widget extension, etc...

I'm sure it would be very useful and helpful to many people!

phazei commented

This would be a really useful feature, right now due to this limitation we need to implement our own custom file store on iOS, would really like to use this library instead.