我正在使用 React Native 和React Navigation以及react-native-deep-linking和react-native-webview包。
我的应用程序正在使用深层链接来访问应用程序的不同屏幕,并且在 iPhone 上打开深层链接工作正常,除了在 WebView 中,如果我按下链接,则没有任何反应。该应用程序甚至对点击链接没有反应,也没有 console.warn 消息等等。
如果我在 iPhone 上使用 Safari,则这些功能可以正常工作,但不能在 WebView 中使用。
这是 WebView 代码:
class BankID extends React.Component {
render() {
return (
<WebView
style={{ flex: 1 }}
source={{ uri: 'https://URL/file.html' }}
/>
);
}
}
export default BankID;
Run Code Online (Sandbox Code Playgroud)
文件.html:
<html>
<body>
<a href="test://1234">App-Link</a>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
从 App.js 我得到了 github repo 中指示的深层链接组件:
componentDidMount() {
DeepLinking.addScheme('test://');
Linking.addEventListener('url', this.handleUrl);
Linking.getInitialURL().then((url) => {
if (url) {
Linking.openURL(url);
}
}).catch(err => …Run Code Online (Sandbox Code Playgroud)