3
votes

I am working on an application in react native, and was taking a look at some tutorials for creating a 'share extension' within the app. I see on npm react-native-share-extension how to create the extension within the project in xcode, and create a new component with a second AppRegistry (shown from npm example).

//index.ios.js 
import React from 'react'
import { AppRegistry } from 'react-native'

import App from './app.ios'
import Share from './share.ios'

AppRegistry.registerComponent('Sample1', () => App)
AppRegistry.registerComponent('MyShareEx', () => Share)

Does anyone know if the share component would have access to the data stored by the main app in AsyncStorage? (i.e my login token)

Thanks!

2
you need to use app groups in order the share data between the app and the extension in IOS - Roy
Thanks Roy, I found how to create the app group in xcode. I'll test it out in the react native code. - squatchman

2 Answers

1
votes

You need to use App Groups. That is where you can store shared data.

There is a plugin for React Native that works very well for iOS. I'm using it myself.

Check out: https://www.npmjs.com/package/react-native-shared-group-preferences

0
votes

I would recommend to use native share extension since share extension have limited memory limit. It causes memory issue if you invoke react app from extenion.