反应本机 - 电话号码与分机
问题描述:
我想打开电话号码与扩展名。 只有电话号码链接作品反应本机 - 电话号码与分机
几个选项尝试
Linking.openURL('tel:XXXXXXXXX,XXX');
Linking.openURL('tel:'+ encodeURIComponent('XXXXXXXXX,XXX'));
拨号器只拨打主号码和犯规包括扩展
我可以写一本机代码和公开方法,但是这将是我的最后一个选项
答
我知道这是晚了,但你可以试试这个组件:react-native-communications。
它适用于iOS和Android。
你要导入的文件中,你需要:
import Communications from 'react-native-communications';
,然后根据你需要使用它:
<TouchableOpacity onPress={() => Communications.phonecall(phoneNumbers[0].number, true)}>
答
这是我尝试过,
callNumber = (url) =>{
Linking.canOpenURL(url).then(supported => {
if (!supported) {
console.log('Can\'t handle url: ' + url);
} else {
return Linking.openURL(url);
}
}).catch(err => console.error('An error occurred', err));
}
和JSX,
<Text onPress={()=> this.callNumber(`tel:+91${user.number}`)}
style = {[styles.value,{marginLeft : 5,textDecorationLine :'underline'}]}>{`+91 ${user.number}`}</Text>
</View>
适合我。 你可能会发现更多的链接在这里, https://facebook.github.io/react-native/docs/linking.html
我只看了这个库的代码,它所做的就是调用相同的Linking.openURL,所以我不知道这是如何有助于这种情况 –