reactjs - React Native 在深度链接时省略了井号键
问题描述
我正在尝试使用本机反应拨打电话号码。但是井号键不会添加到要呼叫的电话号码中。React Native 省略了数字中的“#”键。
dialCall = (number,amount,pin) => {
var phoneNumber = '';
if (Platform.OS === 'android') {
phoneNumber = `tel:*516*${number}*${amount}*${pin}#`
}
else {
phoneNumber = `tel://*516*${number}*${amount}*${pin}#`
}
// console.log("credit transfer",phoneNumber)
Linking.openURL(phoneNumber);
};
render(){
const { navigation} = this.props;
return (
<Background type='primary' style={styles.background}>
<Card style={Styles.container}>
<Text style={Styles.label}>Recipient</Text>
<TextInput
value={this.state.transferRecipient}
style={[Styles.input,flex=1]}
placeholderTextColor='#666666'
onChangeText={(text) => this.setState({transferRecipient:text})}
keyboardType="phone-pad"
/>
<Text style={Styles.label}>Amount</Text>
<TextInput
value={this.state.transferAmount}
style={[Styles.input,flex=1]}
placeholderTextColor='#666666'
onChangeText={(number) => this.setState({transferAmount:number})}
keyboardType="phone-pad"
/>
<View>
<Text style={Styles.label}>Confirm Amount</Text>
<TextInput
value={this.state.confirmTransferAmount}
style={[Styles.input,flex=1]}
placeholderTextColor='#666666'
onChangeText={(number) => this.setState({confirmTransferAmount:number})}
keyboardType="phone-pad"
/>
</View>
<View>
<Text style={Styles.label}>Pin</Text>
<TextInput
value={this.state.pin}
style={[Styles.input,flex=1]}
placeholderTextColor='#666666'
onChangeText={(number) => this.setState({pin:number})}
keyboardType="phone-pad"
/>
</View>
<Button
title="Transfer Now"
onPress=
{()=>this.dialCall(this.state.transferRecipient,this.state.transferAmount,this.state.pin)}
style={Styles.buttonStyle}
disabled={false}
accessibilityLabel='transferCredit'
textAccessibilityLabel='transferCredit'
/>
</Card>
</Background>
我想我在代码中遗漏了一些东西。本机反应会限制磅键被调用还是什么?我可以使用什么替代方式来调用反应本机中的号码
解决方案
我只需要更改 dialCall 函数中的一些变量
dialCall = (number,amount,pin) => {
var phoneNumber = '';
if (Platform.OS === 'android') {
phoneNumber = `tel:*516*${number}*${amount}*${pin}+%23`
}
else {
phoneNumber = `telprompt://*516*${number}*${amount}*${pin}+%23`
}
// console.log("credit transfer",phoneNumber)
Linking.openURL(phoneNumber);
};
推荐阅读
- xsd - XSD:复杂类型的默认值作为字符串
- android - ImageView 高程:阴影在底部被裁剪
- windows - 根据多部分档案文件名中的关键字将相似文件收集到单独的文件夹中
- java - 如何解决孤儿案件?
- python - 从与 JSON 文件链接的静态文件夹加载随机图像
- python - 有没有办法中断 Python 中的shutil copytree 操作?
- xml - 从 xml 字符串中获取特定部分
- php - oci_execute(): ORA-06550: PLS-00306: 错误的参数数量或类型
- typescript - 抽象列表中具体类型的 Typescript 反序列化(JSON.NET 序列化)
- php - 当子实体保存在数据库上时更新 Symfony 父实体时间戳字段