Skip to content

Commit

Permalink
Android: implement Twilio Programmable Voice Android SDK 3.3.0
Browse files Browse the repository at this point in the history
- new feature call hold
- new feature call ringing state
- new feature ConnectOptions
- remove state for callInvite
- handle internal CANCEL_CALL notification
- remove blocks of code for callInvite PENDING
  • Loading branch information
fabriziomoscon committed Jan 18, 2020
1 parent fe6256c commit a897a1f
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 158 deletions.
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
## 4.0.0

- Android
- implement new autolinking react native API
- update Firebase Messaging to 17.3.4 which simplifies how to obtain the FCM token
- Android X migration
- use gradle 5.4.1
- use API 28
- upgrade com.twilio:voice-android to 2.1.0
- upgrade com.twilio:voice-android to 3.3.0
- implement hold call Twilio API
- implement call ringing Twilio event
- remove `call_state` from CallInvite
- iOS
- convert params for connectionDidConnect to => call_to, from => call_from
- convert params for connectionDidDisconnect to => call_to, from => call_from, error => err
- convert params for `connectionDidConnect` to => `call_to`, from => `call_from`
- convert params for `connectionDidDisconnect` to => `call_to`, from => `call_from`, `error` => `err`

- throw an error when listening to events that do not exist

## 3.21.3

Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ This is a React Native wrapper for Twilio Programmable Voice SDK that lets you m

# Twilio Programmable Voice SDK

- Android 2.1.0 (bundled within this library)
- Android 3.3.0 (bundled within this library)
- iOS 2.1.0 (specified by the app's own podfile)

## Breaking changes in v4.0.0
Expand All @@ -21,6 +21,8 @@ This is a React Native wrapper for Twilio Programmable Voice SDK that lets you m
<!-- [END instanceId_listener] -->
```

Data passed to the event `deviceDidReceiveIncoming` does not contain the key `call_state`, because state of Call Invites was removed in Twilio Android v3.0.0

- iOS: params changes for `connectionDidConnect` and `connectionDidDisconnect`

to => call_to
Expand Down Expand Up @@ -254,14 +256,14 @@ TwilioVoice.addEventListener('connectionDidConnect', function(data) {
// Android
// {
// call_sid: string, // Twilio call sid
// call_state: 'PENDING' | 'CONNECTED' | 'ACCEPTED' | 'CONNECTING' 'DISCONNECTED' | 'CANCELLED',
// call_state: 'PENDING' | 'CONNECTED' | 'ACCEPTED' | 'CONNECTING' | 'RINGING' | 'DISCONNECTED' | 'CANCELLED',
// call_from: string, // "+441234567890"
// call_to: string, // "client:bob"
// }
// iOS
// {
// call_sid: string, // Twilio call sid
// call_state: 'PENDING' | 'CONNECTED' | 'ACCEPTED' | 'CONNECTING' 'DISCONNECTED' | 'CANCELLED',
// call_state: 'PENDING' | 'CONNECTED' | 'ACCEPTED' | 'CONNECTING' | 'DISCONNECTED' | 'CANCELLED',
// from: string, // "+441234567890" // issue 44 (https://github.com/hoxfon/react-native-twilio-programmable-voice/issues/44)
// to: string, // "client:bob" // issue 44 (https://github.com/hoxfon/react-native-twilio-programmable-voice/issues/44)
// }
Expand All @@ -274,15 +276,15 @@ TwilioVoice.addEventListener('connectionDidDisconnect', function(data: mixed) {
// | Android
// {
// call_sid: string, // Twilio call sid
// call_state: 'PENDING' | 'CONNECTED' | 'ACCEPTED' | 'CONNECTING' 'DISCONNECTED' | 'CANCELLED',
// call_state: 'PENDING' | 'CONNECTED' | 'ACCEPTED' | 'CONNECTING' | 'RINGING' | 'DISCONNECTED' | 'CANCELLED',
// call_from: string, // "+441234567890"
// call_to: string, // "client:bob"
// err?: string,
// }
// | iOS
// {
// call_sid: string, // Twilio call sid
// call_state: 'PENDING' | 'CONNECTED' | 'ACCEPTED' | 'CONNECTING' 'DISCONNECTED' | 'CANCELLED',
// call_state: 'PENDING' | 'CONNECTED' | 'ACCEPTED' | 'CONNECTING' |'DISCONNECTED' | 'CANCELLED',
// call_from?: string, // "+441234567890"
// call_to?: string, // "client:bob"
// from?: string, // "+441234567890" // issue 44 (https://github.com/hoxfon/react-native-twilio-programmable-voice/issues/44)
Expand All @@ -298,7 +300,7 @@ TwilioVoice.addEventListener('callRejected', function(value: 'callRejected') {})
TwilioVoice.addEventListener('deviceDidReceiveIncoming', function(data) {
// {
// call_sid: string, // Twilio call sid
// call_state: 'PENDING' | 'CONNECTED' | 'ACCEPTED' | 'CONNECTING' 'DISCONNECTED' | 'CANCELLED',
// call_state: 'PENDING' | 'CONNECTED' | 'ACCEPTED' | 'CONNECTING' | 'RINGING' | 'DISCONNECTED' | 'CANCELLED', ==> this is removed in v4
// call_from: string, // "+441234567890"
// call_to: string, // "client:bob"
// }
Expand Down Expand Up @@ -339,6 +341,10 @@ TwilioVoice.ignore()
// mutedValue must be a boolean
TwilioVoice.setMuted(mutedValue)

// put a call on hold
TwilioVoice.setOnHold(holdValue)

// send digits
TwilioVoice.sendDigits(digits)

// should be called after the app is initialized
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'com.android.library'
def DEFAULT_COMPILE_SDK_VERSION = 28
def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3"
def DEFAULT_TARGET_SDK_VERSION = 28
def DEFAULT_SUPPORT_LIB_VERSION = "28.0.0"
def DEFAULT_SUPPORT_LIB_VERSION = "28.0.3"

android {
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
Expand All @@ -50,7 +50,7 @@ dependencies {
def supportLibVersion = rootProject.hasProperty('supportLibVersion') ? rootProject.supportLibVersion : DEFAULT_SUPPORT_LIB_VERSION

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.twilio:voice-android:2.1.0'
implementation 'com.twilio:voice-android:3.3.0'
implementation "com.android.support:appcompat-v7:$supportLibVersion"
implementation 'com.facebook.react:react-native:+'
implementation 'com.google.firebase:firebase-messaging:17.+'
Expand Down
2 changes: 2 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.facebook.react.bridge.ReactApplicationContext;
import com.twilio.voice.CallInvite;
import com.twilio.voice.CancelledCallInvite;

import java.util.List;

Expand Down Expand Up @@ -307,12 +308,18 @@ public void createHangupLocalNotification(ReactApplicationContext context, Strin
}

public void removeIncomingCallNotification(ReactApplicationContext context,
CallInvite callInvite,
CancelledCallInvite callInvite,
int notificationId) {
Log.d(TAG, "removeIncomingCallNotification");
if (BuildConfig.DEBUG) {
Log.d(TAG, "removeIncomingCallNotification");
}
if (context == null) {
Log.e(TAG, "Context is null");
return;
}
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
if (callInvite != null && callInvite.getState() == CallInvite.State.PENDING) {
if (callInvite != null) {
/*
* If the incoming call message was cancelled then remove the notification by matching
* it with the call sid from the list of notifications in the notification drawer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class EventManager {
public static final String EVENT_CONNECTION_DID_CONNECT = "connectionDidConnect";
public static final String EVENT_CONNECTION_DID_DISCONNECT = "connectionDidDisconnect";
public static final String EVENT_DEVICE_DID_RECEIVE_INCOMING = "deviceDidReceiveIncoming";
public static final String EVENT_CALL_STATE_RINGING = "callStateRinging";



public EventManager(ReactApplicationContext context) {
mContext = context;
Expand Down
Loading

0 comments on commit a897a1f

Please sign in to comment.