This is a small module that allows you to initiate a phone call in React Native. Support Android X.
No additional user input is required for Android and the call starts instantly (Apple always asks confirmation since the last iOS updates). This will work on a actual device. The iOS simulator does not support phone call feature.
$ npm install react-native-makephonecall --save
$ react-native link react-native-makephonecall
- In XCode, in the project navigator, right click
Libraries➜Add Files to [your project's name] - Go to
node_modules➜react-native-make-phone-calland addRNMakePhoneCall.xcodeproj - In XCode, in the project navigator, select your project. Add
libRNMakePhoneCall.ato your project'sBuild Phases➜Link Binary With Libraries - Run your project (
Cmd+R)<
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.repartamos.makephonecall;to the imports at the top of the file - Add
new RNMakePhoneCallPackage()to the list returned by thegetPackages()method
- Append the following lines to
android/settings.gradle:include ':react-native-makephonecall' project(':react-native-makephonecall').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-makephonecall/android') - Insert the following lines inside the dependencies block in
android/app/build.gradle:compile project(':react-native-makephonecall')
import Phone from 'react-native-makephonecall';
Phone.makeCall("88855443322");checkPermission (callback) - checks permission to access phone call.
requestPermission (callback) - request permission to access phone call.
Usage as follows:
Phone.checkPermission((err, permission) => {
if (err) throw err;
// Phone.PERMISSION_AUTHORIZED || Phone.PERMISSION_UNDEFINED || Phone.PERMISSION_DENIED
if (permission === 'undefined') {
}
if (permission === 'authorized') {
// yay!
}
if (permission === 'denied') {
// x.x
Phone.requestPermission((error, requestPermission) => {
// ...
})
}
})These methods are only useful on Android.