RN Incoming Call Version 2
React Native module to display custom incoming call activity, best result when using with firebase background messaging. Only for Android since iOS we have VoIP.
Yes I heard you could use self managed ConnectionService thing. But since I'm not an Android expert, this is a solution I found acceptable.
You could also wait for this feature request from react-native-callkeep
to be resolved and have an easier life.
Version 2 Breaking Changes
Hello there! It's been a while since I first public version 1 of this library, which contains some bugs that I don't have much time to fix.
Luckily I got a client project which needs this feature again and now I have time to improve it and make sure all major features work. So here is most of it I guess:
-
More generic incoming call UI.
-
Work nicely with all application state (foreground, background, killed, locked).
-
More flexible APIs.
Thanks to jpudysz's folk of react-native-callkeep, version 2 is heavily depended on it.
Migrate from v1
-
getLaunchParameters()
&clearLaunchParameters()
is now replaced byopenAppFromHeadlessMode()
&getExtrasFromHeadlessMode()
. -
Answer calls from background / killed state no longer open app and send launchParams, you need to listen to
answerCall
event from headless job and triggerbackToForeground
oropenAppFromHeadlessMode
manually.
Getting started
$ npm install react-native-incoming-call --save
or
$ yarn add react-native-incoming-call
Addition installation step
In AndroidManifest.xml
:
-
Add
<activity android:name="com.incomingcall.UnlockScreenActivity" />
line between<application>
tag. -
Add
<uses-permission android:name="android.permission.VIBRATE" />
permission. -
Also, it's recommend to put
android:launchMode="singleInstance"
in<activity android:name=".MainActivity"...
tag to prevent duplicate activities.
For RN >= 0.60, it's done. Otherwise:
$ react-native link react-native-incoming-call
Usage
In App.js
:
;;; // Listen to cancel and answer call events;
In index.js
or anywhere firebase background handler lies:
;;;
Well-known issues
Incoming screen not show on android > 9:
You need to turn on autostart and display pop-up windows permissions manually. I'm searching for a better solution.
No vibration when screen locked:
PR is welcomed! 😂
License
This project is licensed under the MIT License.