无法使用 Linking.openURL 打开电话 [英] Cannot open phone call with Linking.openURL

查看:14
本文介绍了无法使用 Linking.openURL 打开电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Description

Cannot open phone call with Linking.openURL('tel:+123456789')

Environment

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

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,

Steps to Reproduce

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

Expected Behavior

open phone call

Actual Behavior

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

解决方案

I found a solution: you need to convert 'tel:' to 'tel://'

这篇关于无法使用 Linking.openURL 打开电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆