react-native-voip-push-receiver
v1.0.3
Published
VoIP push notification handler for Android
Downloads
2
Readme
React Native Android Voip Push Receiver
This package is for handling incoming voip push notifications on Android (for iOS, you can use this).
Prerequisites
This package listens for FCM messages dispatched by your sip server when an incoming call is about to be routed. It is assumed that you already have notification handling configured for firebase in your react-native app. If you haven't yet, then start here.
Getting started
$ npm install react-native-voip-push-receiver --save
Mostly automatic installation
$ react-native link react-native-voip-push-receiver
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.ReactNativeVoipPushReceiver.RNVoipPushReceiverPackage;
to the imports at the top of the file - Add
new RNVoipPushReceiverPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-voip-push-receiver' project(':react-native-voip-push-receiver').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-voip-push-receiver/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-voip-push-receiver')
In AndroidManifest.xml
...
<service
android:name="com.ReactNativeVoipPushReceiver.RNVoipPushReceiverHandler"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
...
Usage
import { AndroidVoipPushReceiver } from 'react-native-voip-push-receiver';
...
AndroidVoipPushReceiver.setNotificationReceivedListener(() => {
// Force your sip device to register when notification is received
this.handleRegisterSipDevice();
});