WARNING - PLEASE READ:
This is a Pilot release.
That means:
- The SDK and associated open source repo are offered as-is. While we take professional pride in all releases, including Pilots, there may be vulnerabilities or bugs present that we’re not yet aware of.
- We’ve targeted this release to “power users”; documentation is sparse and code samples non-existent. These will come in later (public) releases.
- Although rare in practice, we reserve the right to introduce breaking API changes in future releases before ultimately going stable/GA.
- We will tear out the embedded example app and replace it with a proper Quickstart in our first public release. As such, we do not plan to invest any time into fixing or enhancing the current example app.
- Traditional Twilio Support channels and resources are not available to help.
- We welcome your feedback and SDK bug reports (note: non-example app bugs) via the issues page.
Twilio's Voice React Native SDK allows you to add real-time voice and PSTN calling to your React Native apps.
Please check out the following if you are new to Twilio's Programmable Voice or React Native. Also, please checkout our common issues page or contact [email protected] if you need technical support.
To allow for incoming calls, you need to create a push credential for Android and iOS. Additionally, for Android, you need to download the google-services.json
file from the Firebase console and place it under /app
directory.
An Access Token is required to make outgoing calls or receive incoming calls. Please check out this page for more details on creating Access Tokens.
The package is available through npm.
yarn add @twilio/voice-react-native-sdk
The following simple example demonstrates how to make and receive calls. You will need to implement your own getAccessToken()
method for it to work properly. Please see Access Tokens section for more details or check out the iOS and Android quickstart for examples on how to generate the tokens.
For more information on the Voice React Native SDK API, refer to the API Docs or try running the example app.
The Voice iOS SDK uses the PushKit framework for receiving incoming call push notifications. In order for the app to handle and report the VoIP notifications to CallKit as incoming calls in a timely manner, especially when the app was terminated and launched by the push notification, add the TwilioVoicePushRegistry
object and initialization to the AppDelegate.m
(file name may differ) so the app can always respond to the PushKit callbacks and present the incoming call to the users.
@interface AppDelegate ()
@property (nonatomic, strong) TwilioVoicePushRegistry *twilioVoicePushRegistry;
@end
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// ...
// Initialize PKPushRegistry at launch
self.twilioVoicePushRegistry = [TwilioVoicePushRegistry new];
[self.twilioVoicePushRegistry updatePushRegistry];
return YES;
}
Failing to follow the PushKit & CallKit policy will result in app not able to receive push notifications from the system and present incoming calls.
import { Voice } from '@twilio/voice-react-native-sdk';
const token = getAccessToken();
const voice = new Voice();
// Allow incoming calls
await voice.register(token);
// Handle incoming calls
voice.on('callInvite', (callInvite) => {
callInvite.accept();
});
// Make an outgoing call
const call = await voice.connect(token, params);
See LICENSE