Sud*_*dhu 16 android react-native-android
我正在尝试打开带有分机号码的电话号码.链接仅使用电话号码
尝试了很少的选择
Linking.openURL('tel:XXXXXXXXX,XXX');
Linking.openURL('tel:'+ encodeURIComponent('XXXXXXXXX,XXX'));
Run Code Online (Sandbox Code Playgroud)
拨号器仅拨打主号码,不包括分机号码
我可以编写一个本机代码并公开该方法,但这将是我的最后一个选择
Mar*_*ark 25
我知道它已经晚了,但你可以尝试这个组件:react-native-communications.
它适用于iOS和Android.
您必须在您需要的文件中导入它:
import Communications from 'react-native-communications';
Run Code Online (Sandbox Code Playgroud)
然后根据需要使用它:
<TouchableOpacity onPress={() => Communications.phonecall(phoneNumbers[0].number, true)}>
Run Code Online (Sandbox Code Playgroud)
小智 18
这是我试过的,
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));
}
Run Code Online (Sandbox Code Playgroud)
而JSX,
<Text onPress={()=> this.callNumber(`tel:+91${user.number}`)}
style = {[styles.value,{marginLeft : 5,textDecorationLine :'underline'}]}>{`+91 ${user.number}`}</Text>
</View>
Run Code Online (Sandbox Code Playgroud)
对我来说很好.你可以在这里找到更多链接, https://facebook.github.io/react-native/docs/linking.html