分享给React-Native

3
我正在尝试让安卓设备上的应用程序与我的React-Native应用程序共享。然而,我找不到任何可以帮助我的文档,所以我想知道是否有任何方法可以从其他应用程序分享内容到我的应用程序?
澄清: enter image description here 我正在尝试将我的应用程序添加到此列表中。

您可以参考此问题 https://dev59.com/Smgu5IYBdhLWcg3wxZpL - Alexander Vitanov
1个回答

1
你需要允许其他应用程序启动你的活动。参考此处。
<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>

正如您所注意到的,这个“巫术”会在分享列表中展示您的应用程序。
为了处理负担,请将下面的代码片段放置在您的组件中。任何组件都可以。
componentDidMount() {
        Linking.getInitialURL().then((url) => {
            console.log('Initial url is: ' + url);
        }).catch(err => console.error('An error occurred', err));
    }

这个魅力称为链接。文档在这里找到。

1
尝试过了,但是URL始终为空。 - KPS250

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接