react-native-call-receiver
v1.0.1
Published
## Install * npm install react-native-call-receiver --save * In `android/setting.gradle` ```gradle ... include ':react-native-call-receiver' project(':react-native-call-receiver').projectDir = new File(settingsDir, '../node_modules/react-nativ
Downloads
7
Readme
react-native-call-receiver
Install
- npm install react-native-call-receiver --save
- In
android/setting.gradle
...
include ':react-native-call-receiver'
project(':react-native-call-receiver').projectDir = new File(settingsDir, '../node_modules/react-native-call-receiver')
- In
android/app/build.gradle
...
dependencies {
...
compile project(':react-native-call-receiver')
}
- register module (in android/app/src/main/java/[your-app-namespace]/MainActivity.java)
import ru.getintime.react_native_call_receiver.ReactNativeCallReceiver; // <------ add import
public class MainApplication extends Application implements ReactApplication {
@Override
protected List<ReactPackage> getPackages() {
......
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
......
new ReactNativeCallReceiver()
);
}
}
- add Call receiver permission (in android/app/src/main/AndroidManifest.xml)
...
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
...
- add receiver (in android/app/src/main/AndroidManifest.xml)
...
<receiver android:name=".CallReceiver">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE"/>
</intent-filter>
</receiver>
</application>
Usages
CallReceiver.onActionListener(,,callback); CallReceiver.containsActionListener(,); CallReceiver.removeActionListener(,);
States
RINGING - calling OFFHOOK - answer IDLE - cancel