正如标题所说,我想知道是否有办法在社交网络中分享URL深度链接(例如: twitter、facebook、whatsaap等)。我使用的是这个库react-native-share,但由于它不是web,而是来自应用程序的URL ( URL类似于: myapp:// App /1 (最后一部分是我必须发送的参数)),消息不会显示为超链接,而只是一个简单的字符串,就像社交网络中的普通消息一样。我只想让其他应用程序将它识别为链接,并让它在web浏览器上打开,这样它就会打开我正在开发的应用程序。
发布于 2017-06-05 04:01:30
您需要首先在AndroidManifest.xml中添加此意图过滤器。
<activity
[...]
<intent-filter android:label="filter_react_native">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="www.your-domain.com"
android:pathPrefix="/new/9/read" />
<data android:scheme="appname"
android:host="yourhost" />
</intent-filter>然后,您可以使用react-native提供的Linking应用程序接口来处理您的深层链接。
例如:
componentDidMount() {
Linking.getInitialURL().then((url) => {
if (url) {
console.log('Initial url is: ' + url);
}
}).catch(err => console.error('An error occurred', err));
}发布于 2021-05-16 02:16:44
https://stackoverflow.com/questions/44357854
复制相似问题