【问题标题】:Share to React-Native分享到 React-Native
【发布时间】:2018-03-25 20:40:34
【问题描述】:

我正在尝试将 android 设备上的应用程序共享给我的 react-native 应用程序。但是,我找不到任何可以帮助我的文档,所以我想知道是否有任何方法可以将其他应用中的内容共享到我的应用?

澄清:

我正在尝试将我的应用添加到此列表中

【问题讨论】:

标签: react-native react-native-android


【解决方案1】:

您需要允许其他应用程序启动您的活动。 reference here.

<intent-filter  android:label="Share here!">
              <action android:name="android.intent.action.SEND" />
              <category android:name="android.intent.category.DEFAULT" />
              <data android:mimeType="text/*" />
</intent-filter>

您可能会注意到,Witchcraft 会将您的应用显示在共享列表中。

为了处理这个负担,在你的组件中放置下一个 sn-p。任何组件。

componentDidMount() {
        Linking.getInitialURL().then((url) => {
            console.log('Initial url is: ' + url);
        }).catch(err => console.error('An error occurred', err));
    }

这个符咒叫做Linking。找到文档here

【讨论】:

  • 试过了,但 url 总是为空
猜你喜欢
  • 2022-10-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-24
  • 2018-09-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多