React native — call phone number with extension

后端 未结 2 1725
孤街浪徒
孤街浪徒 2021-02-04 06:19

I am trying to open phone number with extension. Linking works with just phone number

Tried with few options

Linking.openURL(\'tel:XXXXXXXXX,XXX\');

Lin         


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-04 06:26

    This is what i tried,

    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));
    }
    

    And the JSX,

     this.callNumber(`tel:+91${user.number}`)}
           style = {[styles.value,{marginLeft : 5,textDecorationLine :'underline'}]}>{`+91 ${user.number}`}
    
    

    Works fine for me. You may find more on linking here, https://facebook.github.io/react-native/docs/linking.html

提交回复
热议问题