问题描述
无法通过Linking.openURL('tel:+123456789')打开电话
Cannot open phone call with Linking.openURL('tel:+123456789')
环境: 操作系统:macOS High Sierra 10.13.4 节点:8.5.0 纱线:未找到 npm:5.8.0 守望者:找不到 Xcode:Xcode 9.3 Build版本9E145 Android Studio:2.3 AI-162.4069837
Environment: OS: macOS High Sierra 10.13.4 Node: 8.5.0 Yarn: Not Found npm: 5.8.0 Watchman: Not Found Xcode: Xcode 9.3 Build version 9E145 Android Studio: 2.3 AI-162.4069837
包装:(需要=>已安装) 反应:16.3.1 => 16.3.1 react-native: https://github.com/expo /react-native/archive/sdk-27.0.0.tar.gz => 0.55.2 博览会:27.0.1,
Packages: (wanted => installed) 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-链接电话呼叫
打开电话
[Android]Error message
attempt to invoke virtual method 'boolean java.lang.string.endsWith(java.
lang.String)' on a null object reference
推荐答案
我找到了一个解决方案:您需要将'tel:'转换为'tel://'
I found a solution: you need to convert 'tel:' to 'tel://'
这篇关于无法使用Linking.openURL打开电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!