react-native-makephonecall
Introduction
This is a small module that allows you to initiate a phone call in React Native. Support Android X.
NOTE
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.
Getting started
$ npm install react-native-makephonecall --save
Mostly automatic installation
$ react-native link react-native-makephonecall
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-make-phone-call
and addRNMakePhoneCall.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNMakePhoneCall.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- 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')
Usage
; Phone;
Permissions Methods (optional)
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.