search

Home  >  Q&A  >  body text

react-native - 如何解决ReactNative中使用Linking调用iOS系统电话功能出现错误?

在react中使用Linking组件调用iOS的电话功能:

部分代码如下

  _TelePhone(TelephoneNumber){
    Platform.OS==='android'? NativeModules.phone.LawyerTelephone(TelephoneNumber):Linking.openURL('tel:'+TelephoneNumber);
  }

  render() {
    return (
      <Master navigator={this.props.navigator} title="订单详情">
        <ScrollView
          showsHorizontalScrollIndicator={false}  //去除水平滚动条
          showsVerticalScrollIndicator={false}    //去除垂直滚动条
          pagingEnabled={true}  //滚动优化
          style={styles.padding10}
        >
          <View style={{}}>
            <Text style={styles.fontSize16}>案件详情:</Text>
          </View>
          <Text style={styles.lineHeight20}>大舅去二舅家找三舅说四舅被五舅骗去六舅家偷七舅放在八舅柜子里九舅借十舅发给十一舅工资的1000元。大舅去二舅家找三舅说四舅被五舅骗去六舅家偷七舅放在八舅柜子里九舅借十舅发给十一舅工资的1000元。大舅去二舅家找三舅说四舅被五舅骗去六舅家偷七舅放在八舅柜子里九舅借十舅发给十一舅工资的1000元。</Text>

        </ScrollView>
        <View style={styles.btnNext}>
          <TouchableOpacity onPress={()=>this._TelePhone(this.props.TEL)}>
            <Text style={styles.btnText}>开始服务</Text>
          </TouchableOpacity>
        </View>
      </Master>
    )
  }

点击按钮时不能达到跳转到电话应用的效果,后台提示错误

代码如下:

Possible Unhandled Promise Rejection (id: 0):
Unable to open URL: telprompt:18217049979
Error: Unable to open URL: telprompt:18217049979

求大神指点,谢谢!

高洛峰高洛峰2771 days ago619

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 09:56:36

    The problem has been solved. It turned out to be the problem of the simulator. I tested everything on a real device and it was OK

    reply
    0
  • 高洛峰

    高洛峰2017-04-18 09:56:36

    It is recommended that you catch it, otherwise it will not be good if it crashes

    Linking.openURL('tel:'+TelephoneNumber).catch(e=>console.war(e))

    reply
    0
  • Cancelreply