无法使用 Linking.openURL 打开电话呼叫



说明

无法使用 Linking.openURL('tel:+123456789'( 打开电话呼叫

环境

环境: 操作系统: macOS High Sierra 10.13.4 节点:8.5.0 纱线:未找到 NPM:5.8.0 守望者:未找到 Xcode:Xcode 9.3 Build 版本 9E145 安卓工作室: 2.3 AI-162.4069837

软件包:(想要=>已安装( 反应: 16.3.1 => 16.3.1 反应原生:https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz => 0.55.2 博览会: 27.0.1,

重现步骤

import ...
export default class App extends React.Component {
_pressCall=()=>{
const url='tel:+123456789'
Linking.openURL(url)
}
render() {
return (
<View style={styles.container}>
<Button title='call' onPress={this._pressCall}/>
</View>
);
}
}

https://snack.expo.io/@kikoololmdrxdd/test-linking-phone-call

预期行为

打开电话呼叫

实际行为

[Android]Error message
attempt to invoke virtual method 'boolean java.lang.string.endsWith(java.
lang.String)' on a null object reference

我找到了一个解决方案:您需要将"tel:"转换为"tel://"

tel:

在Android上工作

tel://在苹果手机上工作

tel://适用于iPhone和Android。RN 0.61

这对我有用 我找到了一个解决方案:您需要将"tel:"转换为"tel://">

Linking.openURL(tel://${phone}(

最新更新