React native 如何在react native上从webview在浏览器中打开intent://链接?
我想从我的网络视图中打开谷歌地图应用程序中的谷歌地图链接。当链接在外部浏览器中打开,然后指向谷歌地图时,是否可能 这是我正在使用的代码React native 如何在react native上从webview在浏览器中打开intent://链接?,react-native,webview,android-webview,React Native,Webview,Android Webview,我想从我的网络视图中打开谷歌地图应用程序中的谷歌地图链接。当链接在外部浏览器中打开,然后指向谷歌地图时,是否可能 这是我正在使用的代码 <WebView source={{ uri: "https://reactnative.dev" }} ref={this.WEBVIEW_REF} onNavigationStateChange={this.onNavigationStateChange.bind(this)}
<WebView
source={{ uri: "https://reactnative.dev" }}
ref={this.WEBVIEW_REF}
onNavigationStateChange={this.onNavigationStateChange.bind(this)}
/>
我在打开邮件应用程序时遇到了类似的问题。我找到了这个github线程,在那里我意识到我必须用originWhitelist={[*]}替换originWhitelist={['http://*','https://*','intent://*']}。现在mailto:链接打开设备上的邮件应用程序,但不在模拟器中。邮件应用程序未安装在模拟器上
要支持内置url方案之外的更深层链接url,请遵循此指南我在打开邮件应用程序时遇到了类似问题。我找到了这个github线程,在那里我意识到我必须用originWhitelist={[*]}替换originWhitelist={['http://*','https://*','intent://*']}。现在mailto:链接打开设备上的邮件应用程序,但不在模拟器中。邮件应用程序未安装在模拟器上
要支持内置url方案之外的更多深度链接url,请遵循本指南从Webview在谷歌地图应用程序中打开谷歌地图链接的最佳方法是使用“onShouldStartLoadWithRequest”道具 别忘了:
import {Linking} from 'react-native';
代码:
<WebView
source={{ uri: "https://reactnative.dev" }}
onShouldStartLoadWithRequest={event => {
if (event.url.match(/(goo\.gl\/maps)|(maps\.app\.goo\.gl)/) ) {
Linking.openURL(event.url)
return false
}
return true
}}
/>
阅读有关“onShouldStartLoadWithRequest”道具的更多信息从Webview在谷歌地图应用程序中打开谷歌地图链接的最佳方法是使用“onShouldStartLoadWithRequest”道具 别忘了:
import {Linking} from 'react-native';
代码:
<WebView
source={{ uri: "https://reactnative.dev" }}
onShouldStartLoadWithRequest={event => {
if (event.url.match(/(goo\.gl\/maps)|(maps\.app\.goo\.gl)/) ) {
Linking.openURL(event.url)
return false
}
return true
}}
/>
阅读有关“onShouldStartLoadWithRequest”道具的更多信息