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.
Create a function like
AsyncStorage.setSuite('group.example')
and after that AsyncStorage use the App Group's path on iOS.
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.
@Krizzu Can you merge this code in? https://github.com/RZulfikri/async-storage/tree/add/app-group
Here is a related discussion https://github.com/alinz/react-native-share-extension/issues/166
Most helpful comment
@Krizzu access to data in notification extensions, share extensions, etc...