[英]Is it possible to transfer parameter's from one react-native application to another react-native application?
我试图将参数从一个 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 中接收参数?
你可以使用 React Navigation 来处理它们:配置链接
嗯,这真的很容易,当问题发布的那天自己就得到了答案。 因为您可以将参数从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
只是 package 名称,这是必要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.