React native——呼叫 phone 分机号码
React native -- call phone number with extension
我正在尝试打开带有扩展名的 phone 号码。
链接仅适用于 phone number
尝试了几个选项
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
我正在尝试打开带有扩展名的 phone 号码。 链接仅适用于 phone number
尝试了几个选项
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