描述
无法使用Linking.openURL('tel:+123456789')打开电话
环境
环境: OS: macOS High Sierra 10.13.4节点: 8.5.0 Yarn:未找到npm: 5.8.0守望者:未找到Xcode: Xcode 9.3 Build version 9E145 Android Studio: 2.3AI-162.4069837
软件包:(需要安装的=> ) react: 16.3.1 => 16.3.1 react-native:https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz => 0.55.2 expo: 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发布于 2018-06-01 00:32:17
我找到了一个解决方案:您需要将'tel:‘转换为'tel://’
发布于 2019-04-15 10:49:09
tel:在安卓系统上工作
tel://在Iphone上工作
发布于 2020-05-18 15:42:19
tel://适用于iPhone和安卓系统。RN 0.61
https://stackoverflow.com/questions/50272908
复制相似问题