On an incoming call, from react native, call RNCallKeep. ... ConnectionService that the device is ready to make outgoing calls via the native Phone app.
Skiptocontent
{{message}}
react-native-webrtc
/
react-native-callkeep
Public
Notifications
Fork
343
Star
663
iOSCallKitframeworkandAndroidConnectionServiceforReactNative
License
ISClicense
663
stars
343
forks
Star
Notifications
Code
Issues
176
Pullrequests
14
Actions
Projects
0
Wiki
Security
Insights
More
Code
Issues
Pullrequests
Actions
Projects
Wiki
Security
Insights
react-native-webrtc/react-native-callkeep
Thiscommitdoesnotbelongtoanybranchonthisrepository,andmaybelongtoaforkoutsideoftherepository.
master
Branches
Tags
Couldnotloadbranches
Nothingtoshow
{{refName}}
default
Couldnotloadtags
Nothingtoshow
{{refName}}
default
8
branches
32
tags
Code
Clone
HTTPS
GitHubCLI
UseGitorcheckoutwithSVNusingthewebURL.
WorkfastwithourofficialCLI.
Learnmore.
OpenwithGitHubDesktop
DownloadZIP
LaunchingGitHubDesktop
Ifnothinghappens,downloadGitHubDesktopandtryagain.
LaunchingGitHubDesktop
Ifnothinghappens,downloadGitHubDesktopandtryagain.
LaunchingXcode
Ifnothinghappens,downloadXcodeandtryagain.
LaunchingVisualStudioCode
Yourcodespacewillopenonceready.
Therewasaproblempreparingyourcodespace,pleasetryagain.
Latestcommit
manuquentin
Mergepullrequest#596fromohheyitskartik/localboardcastmanager-add-on
…
4b1fa98
Jul19,2022
Mergepullrequest#596fromohheyitskartik/localboardcastmanager-add-on
Android:addinglocalbroadcastmanagersupport(#594Fix)
4b1fa98
Gitstats
600
commits
Files
Permalink
Failedtoloadlatestcommitinformation.
Type
Name
Latestcommitmessage
Committime
.github
Addgithubissuetemplate
Sep9,2019
android
addinglocalboardcastmanagersupport
Jul9,2022
docs
DocumenttheuseofforegroundServiceTypeinAndroid<11
May2,2021
example
Mergepullrequest#564fromreact-native-webrtc/dependabot/npm_and_y…
Apr15,2022
ios
addselectedproperty
May3,2022
.gitignore
initialcommit
Dec28,2016
.npmignore
[Android]SplitsetupintoregisterPhoneAccountandregisterAndroidEv…
Jul16,2020
AUTHORS
Addedmyselftoauthors
May3,2021
LICENSE
Updatedocumentationandlicenceinfiles
Aug14,2019
MIGRATION_v2_v3.md
Preparev3release
Aug20,2019
MIGRATION_v3_v4.md
4.0.0
Nov24,2020
README.md
Mergepullrequest#549fromlinus-komnick/patch-1
Apr15,2022
RNCallKeep.podspec
UseReactfordependencyinpodspec
Dec2,2019
actions.js
Addmissingcomma
Jan18,2022
index.d.ts
addselectedproperty
May3,2022
index.js
AddmissinghasVideoattributeinsomemethods
Apr25,2022
package.json
4.3.3
Apr15,2022
Viewcode
ReactNativeCallKeep
Summary
Demo
Android
iOS
Installation
Usage
Setup
Constants
AndroidSelfManagedMode
API
getInitialEvents
clearInitialEvents
setAvailable
setForegroundServiceSettings
canMakeMultipleCalls
setCurrentCallActive
isCallActive
getCalls
displayIncomingCall
answerIncomingCall
startCall
updateDisplay
endCall
endAllCalls
rejectCall
reportEndCallWithUUID
setMutedCall
setOnHold
setConnectionState
checkIfBusy
checkSpeaker
toggleAudioRouteSpeaker
getAudioRoutes
setAudioRoute
supportConnectionService
hasPhoneAccount(async)
hasOutgoingCall(async)
hasDefaultPhoneAccount
checkPhoneAccountEnabled
isConnectionServiceAvailable
backToForeground
removeEventListener
registerPhoneAccount
registerAndroidEvents
Events
didReceiveStartCallAction
-answerCall
-endCall
-didActivateAudioSession
-didDisplayIncomingCall
-didPerformSetMutedCallAction
-didToggleHoldCallAction
-didChangeAudioRoute
-didPerformDTMFAction
-didLoadWithEvents
-showIncomingCallUi
-silenceIncomingCall
-createIncomingConnectionFailed
-checkReachability
Example
Receivingacallwhentheapplicationisnotreachable.
PushKit
Android11
Debug
Android
Troubleshooting
Contributing
License
README.md
ReactNativeCallKeep
ReactNativeCallKeeputilisesabrandnewiOS10frameworkCallKitandAndroidConnectionServicetomakethelifeeasierforVoIPdevelopersusingReactNative.
FormoreinformationaboutCallKitoniOS,pleaseseeOfficialCallKitFrameworkDocumentorIntroductiontoCallKitbyXamarin
FormoreinformationaboutConnectionServiceonAndroid,pleaseseeAndroidDocumentationandBuildacallingapp
⚠️CallKitandConnectionServiceareonlyavailableonrealdevices,thislibrarywillnotworkonsimulators.
Summary
Demo
Installation
Usage
Constants
AndroidSelfManaged
API
Example
PushKit
Android11
Debug
Troubleshooting
Contributing
License
Demo
Ademoofreact-native-callkeepisavailableinthewazo-react-native-demorepository.
Android
iOS
Installation
npminstall--savereact-native-callkeep
#or
yarnaddreact-native-callkeep
iOS
Android
Usage
Setup
importRNCallKeepfrom'react-native-callkeep';
constoptions={
ios:{
appName:'Myappname',
},
android:{
alertTitle:'Permissionsrequired',
alertDescription:'Thisapplicationneedstoaccessyourphoneaccounts',
cancelButton:'Cancel',
okButton:'ok',
imageName:'phone_account_icon',
additionalPermissions:[PermissionsAndroid.PERMISSIONS.example],
//RequiredtogetaudioinbackgroundwhenusingAndroid11
foregroundService:{
channelId:'com.company.my',
channelName:'Foregroundserviceformyapp',
notificationTitle:'Myappisrunningonbackground',
notificationIcon:'Pathtotheresourceiconofthenotification',
},
}
};
RNCallKeep.setup(options).then(accepted=>{});
iOSonly.
AlternativeoniOSyoucanperformsetupinAppDelegate.m.Doingthisallowscapturingeventspriortothereactnativeeventbridgebeingup.PleasebeawarethatcallingsetupinAppDelegate.mwillignoreanysubsequentcallstoRNCallKeep.setup();.
@implementationAppDelegate
-(BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
self.bridge=[[RCTBridgealloc]initWithDelegate:selflaunchOptions:launchOptions];
[RNCallKeepsetup:@{
@"appName":@"AwesomeApp",
@"maximumCallGroups":@3,
@"maximumCallsPerCallGroup":@1,
@"supportsVideo":@NO,
}];
RCTRootView*rootView=[[RCTRootViewalloc]initWithBridge:self.bridge
moduleName:@"App"
initialProperties:nil];
//========OTHERCODEREDACTED==========
returnYES;
}
options:Object
ios:object
appName:string(required)
ItwillbedisplayedonsystemUIwhenincomingcallsreceived
imageName:string(optional)
Ifprovided,itwillbedisplayedonsystemUIduringthecall
ringtoneSound:string(optional)
Ifprovided,itwillbeplayedwhenincomingcallsreceived;thesystemwillusethedefaultringtoneifthisisnotprovided
handleType:string|array(optional)
Ifprovided,itwilltelliOSwhatkindofhandle(s)(number)yourappcanhandle.
generic
number(default)
email
includesCallsInRecents:boolean(optional)
Ifprovided,callswillbeshownintherecentcallswhentrueandnotwhenfalse(ios11andabove)(Default:true)
maximumCallGroups:string(optional)
Ifprovided,themaximumnumberofcallgroupssupportedbythisapplication(Default:3)
maximumCallsPerCallGroup:string(optional)
Ifprovided,themaximumnumberofcallsinasinglegroup,usedforconferencing(Default:1,noconferencing)
supportsVideo:boolean(optional)
Ifprovided,whetherornottheapplicationsupportsvideocalling(Default:true)
displayCallReachabilityTimeout:numberinms(optional)
Ifprovided,startsatimeoutthatchecksiftheapplicationisreachableandendsthecallifnot(Default:null)
You'llhavetocallsetReachable()assoonasyourJavascriptapplicationisstarted.
android:object
alertTitle:string(required)
Whenaskingforphoneaccountpermission,weneedtoprovideratitlefortheAlerttoasktheuserforit
alertDescription:string(required)
Whenaskingforphoneaccountpermission,weneedtoprovideradescriptionfortheAlerttoasktheuserforit
cancelButton:string(required)
Cancelbuttonlabel
okButton:string(required)
Okbuttonlabel
imageName:string(optional)
TheimagetouseintheAndroidPhoneapplication'snativeUIforenabling/disablingcallingaccounts.Shouldbea48x48HDPI
grayscalePNGimage.Mustbeinyourdrawableresourcesfortheparentapplication.Mustbelowercaseandunderscore(_)characters
only,asJavadoesn'tlikecapitallettersonresources.
additionalPermissions:[PermissionsAndroid](optional)
Anyadditionalpermissionsyou'dlikeyourapptohaveatfirstlaunch.Canbeusedtosimplifypermissionflowsandavoid
multiplepopupstotheuseratdifferenttimes.
selfManaged:boolean(optional)
Whensettotrue,callkeepwillconfigureitselftorunasaselfmanagedconnectionservice.Thisisanadvancedtopic,andit'sbesttorefertoGooglesDocumentationonthematter.
displayCallReachabilityTimeout:numberinms(optional)
Ifprovided,startsatimeoutthatchecksiftheapplicationisreachableandendsthecallifnot(Default:null)
You'llhavetocallsetReachable()assoonasyourJavascriptapplicationisstarted.
setupcallsinternallyregisterPhoneAccount,registerEventsandsetSettings.
YoucanalternativelyjustcallsetSettings()withthesameoptionassetup()todefineonlyyoursettings.
Constants
Tomakepassingtherightintegerintomethodseasier,thereareconstantsthatareexportedfromthemodule.
constCONSTANTS={
END_CALL_REASONS:{
FAILED:1,
REMOTE_ENDED:2,
UNANSWERED:3,
ANSWERED_ELSEWHERE:4,
DECLINED_ELSEWHERE:5,
MISSED:6
}
};
const{CONSTANTSasCK_CONSTANTS,RNCallKeep}from'react-native-callkeep';
console.log(CK_CONSTANTS.END_CALL_REASONS.FAILED)//outputs1
AndroidSelfManagedMode
ThisfeatureisavailableonlyonAndroid.
Androidsupportscallingappsrunninginwhat'scalled"SelfManaged".Thismeanstheappsareable(andrequired)toprovidetheirownUIformanagingcalls.ThisincludesbothincallUIelementsandincomingcallnotificationUI.Thismethodisallornothing.Youcan'tmixpartialelements,suchashavingacustomincallview,butusethedefaultincomingcallUI.
Toimplementaselfmanagedcallingapp,thefollowingstepsarenecessary:
SetselfManaged:trueinsetup.
Onanincomingcall,fromreactnative,callRNCallKeep.displayIncomingCall
CallKeepwillthenfiretheshowIncomingCallUievent.
WhenshowIncomingCallUiisfired,youmustshowanincomingcallUI.Thiswouldbeahighprioritynotification(Android:Displaytime-sensitivenotifications).
Iftheuseranswersthecall,youcalltheappropriateRNCallKeepactionssuchasanswerCallorendCall
IncertaincasesAndroidwillnotallowyoutoshowanincomingcallnotification.Inthatcasethe'createIncomingConnectionFailed'eventisfiredandyoushouldrejecttheincomingSIPInvite.
SelfManagedcallingappsareanadvancedtopic,andtherearemanystepsinvolvedinimplementingthem,butherearesomethingstokeepinmind:
ReactNativeHeadlessTasksareagreatwaytoexecuteReactNativecode.RemembertostartuptheheadlesstaskasaForegroundService.
AndroidwilldeprioritizeyourhighpriorityFCMnotificationsifyoufailtoshowanincomingcalluiwhenreceivingthem.
YoucanavoidgettingfloodedwithstickyforegroundservicenotificationsbynotdefiningaForegroundServiceforCallKeep,andinsteadmanagingthisonyourown.
⚠️Tobeabletousetheselfmanagedmode,you'llhavetoaddtheREAD_CALL_LOGpermissioninyourandroid/src/main/AndroidManifest.xmlfile:
API
Method
ReturnType
iOS
Android
getInitialEvents()
Promise
✅
✅
clearInitialEvents()
void>
✅
✅
setAvailable()
Promise
❌
✅
setForegroundServiceSettings()
Promise
❌
✅
canMakeMultipleCalls()
Promise
❌
✅
setCurrentCallActive()
Promise
❌
✅
isCallActive()
Promise
✅
❌
getCalls()
Promise