javascript - 是否可以将参数从一个 react-native 应用程序传输到另一个 react-native 应用程序?
问题描述
我试图将参数从一个 react-native 应用程序传递到另一个 react-native 应用程序。我知道这是可能的并且在 Android 中做得很好,但只是想知道如何在 react-native 中完成它。
一个调用者应用程序让我们说 Param_send_App、Param_receive_app。
从 Param_send_App 我会打电话Linking.openURL('param_receive_app://app?param1=test¶m2=test2')
,但我将如何在 Param_receive_app 接收参数?
解决方案
嗯,这真的很容易,当问题发布的那天自己就得到了答案。因为您可以将参数从Param_send_App 传递 给Param_receive_app
Linking.getInitialURL().then((url) => {
if (url) {
console.log(url);
}
else {
console.log("No Parameter found, perform any other operation");
}
}).catch(err => console.error('Silently capture the error', err));
但是还有一件事要做在 AndroidManifest.xml 中添加
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="param_receive_app" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.param_receive_app" />
</intent-filter>
哪里param_receive_app
是必需的包名。
推荐阅读
- r - 第一个参数不是开放的 RODBC 通道
- c++ - 为什么可变参数函数不适用于模板
- python - 如何拆分成二维数组python
- google-maps - Google 地址建议国家/地区限制无法正常工作
- java - 如何在我的 batis 中从 database.confid 中读取属性值
- c# - 列表
循环后不保存 - powershell - 为什么 PowerShell 中的变量扩展为 `-encodedCommand` 而不是其实际值?
- postgresql - Postgresql:为什么 \d+ 表不显示默认为空
- c# - 使用 Jenkins 自动部署 Service Fabric 应用程序会产生“目标不存在”错误
- python - 为什么一维 k 均值聚类比 k 均值初始化混合模型拟合慢?