alinz / react-native-share-extension

react-native as an engine to drive share extension
MIT License
763 stars 398 forks source link

Shared bundles issue #70

Open sonirad88 opened 6 years ago

sonirad88 commented 6 years ago

Hi. I need solution where my extension and main app will share same storage (use AsyncStorage). Guess shared bundles will help me achieve that? Following the steps i stop on two issues:

  1. cant find appShareExtension target's "Bundle React Native code and images" phase
  2. what is cp-native-assets? script or? Thanks in advance
TheTekton commented 6 years ago

Might need to make a PR to help clarify the docs and add some images; will try to make some time early in the week. The extension and main app containers are isolated from one another. You will need to create an app group with your Apple Developer account. See "Adding an App to an App Group". Then, they can use a shared container. See "Sharing Data with Your Containing App".

Without looking, I'm pretty sure AsyncStorage is local to the app's container, without support for shared containers. You can use something like react-native-fs to replace AsyncStorage. There are other options too, but that should be a good starting point.

  1. The "Bundle React Native code and images" phase is normally where the react-native packager script react-native-xcode.sh is called from. Not sure if it's changed in the latest create-react-native-app implementation; can look later. screen shot 2017-12-03 at 5 34 59 pm
  2. cp-native-assets npm script would just be an in-house script that copies assets that are needed in the share extension react-native app. Likely unnecessary, could probably update the docs with an example or strip that altogether, depending on what makes most sense. Will look at this soon.
TheTekton commented 6 years ago

@sonirad88 Let me know if you have further questions. I can try to clarify more, if necessary.

sonirad88 commented 6 years ago

Thanks @TheTekton for good explanation. I thought that shared bundles will help me use AsyncStorage for both my extension and main app but now i see that only option to me is open App Group. Im waiting for my developer account so i can create group and probably i will use this library from alinz 'react-native-swiss-knife' (probably i will change instead string to store array/dictionary). I hope that i can also store files in that shared container of app group because my extension and main app should be able store .pdf files that can be visible for both (as i can see now they store file in different place). FYI im not iOs dev :)

anasalsaadi14 commented 3 years ago

what is the solution to use asyncStorage with main app and share extension ??