Skip to content

Open PR Bundle - iOS and Android to v5 #145

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 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
[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
- Android X migration
- use gradle 5.4.1
- use API 28
- upgrade com.twilio:voice-android to 2.1.0
- 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.3

- iOS: Upgrade TwilioVoice pod to version 2.1
Expand Down
88 changes: 28 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,15 @@
# react-native-twilio-programmable-voice
This is a React Native wrapper for Twilio Programmable Voice SDK that lets you make and receive calls from your ReactNatvie App. This module is not curated nor maintained, but inspired by Twilio.
This is a React Native wrapper for Twilio Programmable Voice SDK that lets you make and receive calls from your React Native App. This module is not affiliated with or maintained by the Twilio team. This is maintained by contributions from the community.

# Twilio Programmable Voice SDK

- Android 2.0.7 (bundled within this library)
- iOS 2.0.4 (specified by the app's own podfile)
- Android 5.0.2 (bundled within this library)
- iOS 5.1.1 (specified by the app's own podfile; min. version 5.x)

## 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 +19,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`

If something doesn't work as expected or you want to make a request open an issue.
to => call_to
from => call_from
error => err

## 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 All @@ -68,7 +45,7 @@ ReactNative success is directly linked to its module ecosystem. One way to make
## Installation

Before starting, we recommend you get familiar with [Twilio Programmable Voice SDK](https://www.twilio.com/docs/api/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.
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. On RN 0.60+, this module can be auto-linked (Android still requires FCM setup below).


```
Expand All @@ -86,11 +63,11 @@ Edit your `Podfile` to include TwilioVoice framework
source 'https://github.com/cocoapods/specs'

# min version for TwilioVoice to work
platform :ios, '8.1'
platform :ios, '10.0'

target <YOUR_TARGET> do
...
pod 'TwilioVoice', '~> 2.1.0'
pod 'TwilioVoice', '~> 5.1.1'
...
end

Expand All @@ -105,11 +82,11 @@ Edit your `Podfile` to include TwilioVoice and RNTwilioVoice frameworks
source 'https://github.com/cocoapods/specs'

# min version for TwilioVoice to work
platform :ios, '8.1'
platform :ios, '10.0'

target <YOUR_TARGET> do
...
pod 'TwilioVoice', '~> 2.1.0'
pod 'TwilioVoice', '~> 5.1.1'
pod 'RNTwilioVoice', path: '../node_modules/react-native-twilio-programmable-voice'
...
end
Expand Down Expand Up @@ -143,16 +120,17 @@ It contains keys and settings for all your applications under Firebase. This lib
buildscript {
...
dependencies {
classpath 'com.google.gms:google-services:3.1.2'
classpath 'com.google.gms:google-services:4.2.0'
}
}

...

dependencies {
...
// on React Native 0.60+, this module can be auto-linked and doesn't need a manual entry here

compile project(':react-native-twilio-programmable-voice')
implementation project(':react-native-twilio-programmable-voice')
}

// this plugin looks for google-services.json in your project
Expand All @@ -179,22 +157,12 @@ In your `AndroidManifest.xml`
</intent-filter>
</service>
<!-- [END fcm_listener] -->
<!-- [START instanceId_listener] -->
<service
android:name="com.hoxfon.react.RNTwilioVoice.fcm.VoiceFirebaseInstanceIDService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<!-- [END instanceId_listener] -->
<!-- Twilio Voice -->

.....

```

In `android/settings.gradle`
In `android/settings.gradle` (not necessary if auto-linking on RN 0.60+)

```gradle
...
Expand All @@ -203,7 +171,7 @@ include ':react-native-twilio-programmable-voice'
project(':react-native-twilio-programmable-voice').projectDir = file('../node_modules/react-native-twilio-programmable-voice/android')
```

Register module (in `MainApplication.java`)
Register module (in `MainApplication.java`) (not necessary if auto-linking on RN 0.60+ unless you want to control microphone permission)

```java
import com.hoxfon.react.RNTwilioVoice.TwilioVoicePackage; // <--- Import Package
Expand All @@ -220,8 +188,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
4 changes: 2 additions & 2 deletions RNTwilioVoice.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ Pod::Spec.new do |s|
s.authors = spec['author']['name']
s.homepage = spec['homepage']
s.license = spec['license']
s.platform = :ios, "8.1"
s.platform = :ios, "10.0"

s.source_files = [ "ios/RNTwilioVoice/*.h", "ios/RNTwilioVoice/*.m"]
s.source = {:path => "./RNTwilioVoice"}

s.dependency 'React'
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '${PODS_ROOT}/TwilioVoice' }
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '${PODS_ROOT}/TwilioVoice/Build/iOS' }
s.frameworks = 'TwilioVoice'
end
34 changes: 20 additions & 14 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

buildscript {
repositories {
google()
jcenter()
}
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.5.2'
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 +16,24 @@ buildscript {

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

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"

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,10 +47,12 @@ android {
}

dependencies {
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.facebook.react:react-native:+'
compile 'com.google.firebase:firebase-messaging:17.+'
testCompile 'junit:junit:4.12'
def supportLibVersion = rootProject.hasProperty('supportLibVersion') ? rootProject.supportLibVersion : DEFAULT_SUPPORT_LIB_VERSION

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.twilio:voice-android:5.0.2'
implementation "com.android.support:appcompat-v7:$supportLibVersion"
implementation 'com.facebook.react:react-native:+'
implementation 'com.google.firebase:firebase-messaging:17.+'
testImplementation 'junit:junit:4.12'
}
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
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-5.4.1-all.zip
Empty file removed android/settings.gradle
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
import android.os.Build;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;
import android.support.v4.app.NotificationCompat;
import androidx.core.app.NotificationCompat;
import android.util.Log;
import android.view.WindowManager;

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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.hoxfon.react.RNTwilioVoice;

import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import android.util.Log;

import com.facebook.react.bridge.ReactApplicationContext;
Expand Down
Loading