我正在尝试打开分机号码。链接只与电话号码有关
try with few options
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