react-native-twilio-voice-sdk
This is a React Native wrapper for Twilio Programmable Voice SDK that lets you make (and in the future receive) calls from your ReactNative App. This module is not curated nor maintained, but inspired by Twilio.
The initial version of this library was forked from react-native-twilio-programmable-voice in order to update Twilio's programmable Voice SDK libraries to their latest version. This is specially important because version 2 of Twilio's libraries used by react-native-twilio-programmable-voice
is going to be deprecated by Jan, 1st 2020. In order to simplify the migration, only the making calls part was migrated.
Twilio Programmable Voice SDK
- Android 4.1.0
- iOS 4.1.0
Installation
Before starting, we recommend you get familiar with Twilio Programmable Voice SDK. It's easier to integrate this module into your react-native app if you follow the Quick start tutorial from Twilio, because it makes very clear which setup steps are required.
This library only intends to support React Native versions over 0.60. This doesn't mean that it won't work with previous versions, just that issues related to previous versions of RN won't be actively tracked by the mantainer.
npm install react-native-twilio-voice-sdk --save
Usage
The library tries to mimic the Twilio Voice SDK API for Android and iOS with some idiomatic changes for Javascript.
The SDK is composed of several key classes illustrated in the image below.
The class TwilioVoice is the entry point into the SDK and does the following:
- Make outgoing calls with TwilioVoice.connect(...)
- The class Call represents an outgoing call.
Code example
// Get the library versionTwilioVoiceversion // Get the underlying native TwilioVoice library versionTwilioVoicenativeVersion // Subscribe to call eventslet callconst removeSubscription = TwilioVoice// call removeSubscription() to stop listening // start a callTwilioVoice // hangupcall // mute or un-mute the call// mutedValue must be a booleancall // Send the call audio to the speaker phone// speakerPhoneEnabled must be a booleancall call // Call propertiescallfromcalltocallsidcallstate // "RINGING" | "CONNECTING" | "CONNECTED" | "RECONNECTING" | "DISCONNECTED"
Events
All calls to the on
method return a function that removes the subscription upon execution.
TwilioVoice
Twilio Voice SDK reference
Credits
react-native-twilio-programmable-voice
react-native-push-notification
License
MIT