React Native Share Extension - 访问AsyncStorage?

时间:2017-11-03 18:22:59

标签: ios react-native

我正在使用本机的应用程序,并正在查看一些在应用程序中创建“共享扩展”的教程。我在npm react-native-share-extension上看到如何在xcode中创建项目中的扩展,并使用第二个AppRegistry创建一个新组件(从npm示例中显示)。

//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)

是否有人知道共享组件是否可以访问AsyncStorage中主应用程序存储的数据? (即我的登录令牌)

谢谢!

2 个答案:

答案 0 :(得分:1)

您需要使用应用程序组。这是您可以存储共享数据的地方。

React Native有一个适用于iOS的插件。我自己用它。

退房:https://www.npmjs.com/package/react-native-shared-group-preferences

答案 1 :(得分:0)

由于共享扩展名具有有限的内存限制,因此我建议使用本机共享扩展名。如果您从扩展中调用react应用,则会导致内存问题。