MaxAst / expo-share-extension

Expo config plugin for creating iOS share extensions with a custom view.
MIT License
205 stars 4 forks source link

Sharing data between main app and share extension #18

Closed Mohamed3on closed 5 months ago

Mohamed3on commented 5 months ago

Hey Max, thanks a lot for building this!

I'm trying the plugin and wanted to share auth between the main app and the Share Extension. I saw your firebase solution using useUserAccessGroup which works very well, but I wanted to use Supabase instead for my database.

My idea was to login in the main app, then store the access token somewhere, and access it in the share extension. Is there any way to do that? Similar to a global context in React.

Thanks!

jkinggg commented 5 months ago

This library looks awesome. I'm also interested in understanding how we can share details between the share app and the main app, whether it's sharing auth details or sending content from the share app to the main app.

MaxAst commented 5 months ago

Hey @Mohamed3on & @jkinggg, happy to hear you're excited about this plugin! To answer your question:

You should be able to achieve this easily in combination with this MMKV package. It supports app groups out of the box and will automatically use the app group that expo-share-extension creates for you - so you don't need to do anything, it should just work 😄

Bear in mind that MMKV should only be used for small things like auth tokens etc. For sharing content it's a little more complicated and I would need to put in some more work into this plugin. This is on my agenda and I'm planning to release photo + video support very soon

kayode0x commented 5 months ago

in my case, rn mmkv didn't work out of the box so i used react-native-shared-group-preferences

export-mike commented 5 months ago

yeah I had a go at using MMKV it just never seem to pick up the saved tokens within the extension which are set in the main app...

I've been using react-native-keychain which works but there is a weird case when the extension goes to refresh the refreshToken it seems its unable to succeed and save the new tokens.

An example here would be really appreciated @MaxAst 🙏

MaxAst commented 5 months ago

Hey @kayode0x & @export-mike, thanks for reporting this. You're right, react-native-mmkv indeed doesn't work out of the box. I missed a small detail in their README, saying that we need to set an AppGroup key in Info.plist to the value of our app group's name. I just created a PR that fixes this #19. I'll create a release in a minute

MaxAst commented 5 months ago

Release done, you should be able to try this with the latest version (1.5.2). Closing this for now, let me know in case you still run into any issues