lucasferreira / react-native-send-intent

React Native Android module to use Android's Intent actions for send text to shareable apps or make phone calls or opening third party apps
419 stars 159 forks source link

SendIntentAndroid.sendPhoneCall not working for me #82

Open ayozebarrera opened 5 years ago

ayozebarrera commented 5 years ago

Hi, gj by the way!

I need to call to a number without exiting my app and if I use SendIntentAndroid.sendPhoneCall('+55 48 9999-9999'); it shows up the phone dial, and If I add the 2nd parameter SendIntentAndroid.sendPhoneCall('+55 48 9999-9999', true); nothing happens... what am I doing wrong?

I added the on AndroidManifest.xml

Thanks for the help and merry xmas!

huunghi20061997 commented 5 years ago

I have a similar situation

lucasferreira commented 5 years ago

Hi @ayozebarrera and @huunghi20061997

Maybe your Android API it's too high (and modern) so you need to ask the permission in runtime (besides the permission added in AndroidManifest.xml).

You could do something like that width https://facebook.github.io/react-native/docs/permissionsandroid:

async function requestCallPhone() {
  try {
    const granted = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.CALL_PHONE, {
        'title': 'App Call Phone Permission',
        'message': 'App needs access to your call phone feature'
      }
    )
    if (granted === PermissionsAndroid.RESULTS.GRANTED) {
      SendIntentAndroid.sendPhoneCall('+55 48 9999-9999', true);
    } else {
      console.log("Call Phone permission denied")
    }
  } catch (err) {
    console.warn(err)
  }
}
ayozebarrera commented 5 years ago

I'll try, thanks for the help <3