Skip to content

Twilio Voice Android SDK 4 #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cc2a39c
Fix end-call flow to avoid unknown UUID error
fabriziomoscon Dec 15, 2018
d2b9c45
fix: align iOS params to Android
fabriziomoscon Dec 15, 2018
d0ef916
update: android to com.twilio:voice-android:2.0.9
fabriziomoscon Dec 15, 2018
fb6849a
update: Android firebase-messaging to 17.3.4
fabriziomoscon Dec 15, 2018
f6a5a52
formatting
fabriziomoscon Dec 15, 2018
13faff5
fix: align lib dependency with root
fabriziomoscon Dec 27, 2018
3e18619
v4.0.0
fabriziomoscon Dec 15, 2018
c9714a3
React 59+ compat
Pagebakers Sep 27, 2019
ed1b70b
Correct version
Pagebakers Sep 27, 2019
8351458
Revert version
Pagebakers Sep 27, 2019
182b9bf
Upgrade to Twilio Sdk 4
Pagebakers Sep 27, 2019
2de78fd
Use new api
Pagebakers Sep 27, 2019
e7a8210
Forgot semi colon
Pagebakers Sep 27, 2019
58a1d3c
Fix identation
Pagebakers Sep 27, 2019
65260e3
Update notifications
Pagebakers Sep 27, 2019
aae20ae
Use connect options
Pagebakers Sep 27, 2019
9342131
Add onReconnect method
Pagebakers Sep 27, 2019
b236cb6
Fix typo
Pagebakers Sep 27, 2019
1f44944
Handle cancel invite
Pagebakers Sep 27, 2019
a31039e
Add CancelledCallInvite
Pagebakers Sep 27, 2019
359ef68
CANCELLED_CALL_INVITE
Pagebakers Sep 27, 2019
663b237
Add cancel action
Pagebakers Sep 27, 2019
9938225
Make final
Pagebakers Sep 27, 2019
ae3362c
Handle cancelled call
Pagebakers Sep 27, 2019
dc162d3
Merge branch 'feat/v4' into feature/android-sdk-4
Pagebakers Dec 13, 2019
f299970
update compile versions
Pagebakers Dec 13, 2019
c765352
Update support lib minor version
Pagebakers Dec 13, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
[Release Section](https://github.com/hoxfon/react-native-twilio-programmable-voice/releases)

## 4.0.0
- Android
- update Firebase Messaging to 17.3.4 which simplifies how to obtain the FCM token
- iOS
- convert params for connectionDidConnect to => call_to, from => call_from
- convert params for connectionDidDisconnect to => call_to, from => call_from, error => err

## 3.21.1
- Android: fix crash when asking for microphone permission before an activity is displayed

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

# Twilio Programmable Voice SDK

- Android 2.0.7 (bundled within this library)
- iOS 2.0.4 (specified by the app's own podfile)
- Android 2.0.9 (bundled within this library)
- iOS 2.0.7 (specified by the app's own podfile)

## Breaking changes in v3.0.0

- initWitToken returns an object with a property `initialized` instead of `initilized`
- iOS event `connectionDidConnect` returns the same properties as Android
move property `to` => `call_to`
move property `from` => `call_from`

## Migrating Android from v1 to v2 (incoming call use FCM)

You will need to make changes both on your Twilio account using Twilio Web Console and on your react native app.
Twilio Programmable Voice Android SDK uses `FCM` since version 2.0.0.beta5.

Before you start, I strongly suggest that you read the list of Twilio changes from Android SDK v2.0.0 beta4 to beta5:
[Twilio example App: Migrating from GCM to FCM](https://github.com/twilio/voice-quickstart-android/blob/d7d4f0658e145eb94ab8f5e34f6fd17314e7ab17/README.md#migrating-from-gcm-to-fcm)

These are all the changes required:

- remove all the GCM related code from your `AndroidManifest.xml` and add the following code to receive `FCM` notifications
(I wasn't successful in keeping react-native-fcm working at the same time. If you know how please open an issue to share).
## Breaking changes in v4.0.0

- Android: remove the following block from your application's `AndroidManifest.xml`
```xml
.....

<!-- Twilio Voice -->
<!-- [START fcm_listener] -->
<service
android:name="com.hoxfon.react.TwilioVoice.fcm.VoiceFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- [END fcm_listener] -->
<!-- [START instanceId_listener] -->
<service
android:name="com.hoxfon.react.TwilioVoice.fcm.VoiceFirebaseInstanceIDService"
Expand All @@ -47,15 +21,20 @@ These are all the changes required:
</intent-filter>
</service>
<!-- [END instanceId_listener] -->
<!-- Twilio Voice -->
```

- log into your Firebase console. Navigate to: Project settings > CLOUD MESSAGING. Copy your `Server key`
- in Twilio console add a new Push Credential, type `FCM`, fcm secret Firebase FCM `Server key`
- include in your project `google-services.json`; if you have not include it yet
- rename getIncomingCall() to getActiveCall()
- iOS: params changes for `connectionDidConnect` and `connectionDidDisconnect`

to => call_to
from => call_from
error => err

If something doesn't work as expected or you want to make a request open an issue.
## Breaking changes in v3.0.0

- initWitToken returns an object with a property `initialized` instead of `initilized`
- iOS event `connectionDidConnect` returns the same properties as Android
move property `to` => `call_to`
move property `from` => `call_from`

## Help wanted!

Expand Down Expand Up @@ -220,8 +199,8 @@ public class MainApplication extends Application implements ReactApplication {
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new TwilioVoicePackage() // <---- Add the Package : by default it will ask microphone permissions
// new TwilioVoicePackage(false) // <---- pass false to handle microphone permissions in your application
new TwilioVoicePackage() // <---- Add the package
// new TwilioVoicePackage(false) // <---- pass false if you don't want to ask for microphone permissions
);
}
};
Expand Down Expand Up @@ -277,7 +256,7 @@ 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' | 'RECONNECTING' | 'DISCONNECTED' | 'CANCELLED',
// call_from: string, // "+441234567890"
// call_to: string, // "client:bob"
// }
Expand All @@ -297,7 +276,7 @@ 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' | 'RECONNECTING' | 'DISCONNECTED' | 'CANCELLED',
// call_from: string, // "+441234567890"
// call_to: string, // "client:bob"
// err?: string,
Expand All @@ -321,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' | 'RECONNECTING' | 'DISCONNECTED' | 'CANCELLED',
// call_from: string, // "+441234567890"
// call_to: string, // "client:bob"
// }
Expand Down
31 changes: 22 additions & 9 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

buildscript {
repositories {
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.google.gms:google-services:3.1.2'
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.2.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -15,21 +20,27 @@ buildscript {

allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
}

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.3"

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
Expand All @@ -43,9 +54,11 @@ android {
}

dependencies {
def supportLibVersion = rootProject.hasProperty('supportLibVersion') ? rootProject.supportLibVersion : DEFAULT_SUPPORT_LIB_VERSION

compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.twilio:voice-android:2.0.7'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.twilio:voice-android:4+'
compile 'com.android.support:appcompat-v7:$supportLibVersion'
compile 'com.facebook.react:react-native:+'
compile 'com.google.firebase:firebase-messaging:17.+'
testCompile 'junit:junit:4.12'
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https://services.gradle.org/distributions/gradle-4.10.2-all.zip
Empty file removed android/settings.gradle
Empty file.
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,12 @@ public void createHangupLocalNotification(ReactApplicationContext context, Strin
}

public void removeIncomingCallNotification(ReactApplicationContext context,
CallInvite callInvite,
CancelledCallInvite callInvite,
int notificationId) {
Log.d(TAG, "removeIncomingCallNotification");
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
Loading