Skip to content

Commit

Permalink
fix: default compile Android SDK version 31
Browse files Browse the repository at this point in the history
Twilio lib v6.0.0
  • Loading branch information
fabriziomoscon committed Aug 14, 2023
1 parent ca3468b commit 47a926a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 47 deletions.
52 changes: 29 additions & 23 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

ext.versions = [
'java' : JavaVersion.VERSION_1_8,
'androidGradlePlugin': '4.1.3',
'googleServices' : '4.3.4',
'compileSdk' : 31,
'buildTools' : '30.0.2',
'minSdk' : 23,
'targetSdk' : 30,
'firebase' : '19.0.+',
'voiceAndroid' : '6.0.0',
'audioSwitch' : '1.1.2',
'androidxLifecycle' : '2.2.0',
]

repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.google.gms:google-services:4.3.4'
classpath "com.android.tools.build:gradle:${versions.androidGradlePlugin}"
classpath "com.google.gms:google-services:${versions.googleServices}"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -24,22 +39,16 @@ allprojects {

apply plugin: 'com.android.library'

def DEFAULT_MIN_SDK_VERSION = 23
def DEFAULT_COMPILE_SDK_VERSION = 30
def DEFAULT_BUILD_TOOLS_VERSION = "29.0.3"
def DEFAULT_TARGET_SDK_VERSION = 29
def DEFAULT_SUPPORT_LIB_VERSION = "29.0.3"

android {
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : versions.compileSdk
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : versions.buildTools
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
sourceCompatibility versions.java
targetCompatibility versions.java
}
defaultConfig {
minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : DEFAULT_MIN_SDK_VERSION
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : versions.minSdk
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : versions.targetSdk
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
Expand All @@ -53,14 +62,11 @@ android {
}

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

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.twilio:audioswitch:1.1.2'
implementation 'com.twilio:voice-android:5.4.2'
implementation "com.android.support:appcompat-v7:$supportLibVersion"
implementation 'com.facebook.react:react-native:+'
implementation 'com.google.firebase:firebase-messaging:19.0.+'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.12'
implementation "com.twilio:audioswitch:${versions.audioSwitch}"
implementation "com.twilio:voice-android:${versions.voiceAndroid}"
implementation "com.facebook.react:react-native:+"
implementation "com.google.firebase:firebase-messaging:${versions.firebase}"
implementation "androidx.lifecycle:lifecycle-extensions:${versions.androidxLifecycle}"
testImplementation "junit:junit:4.12"
}
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-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void createMissedCallNotification(ReactApplicationContext context, String
context,
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
);

PendingIntent clearMissedCallsCountPendingIntent = PendingIntent.getBroadcast(
Expand Down Expand Up @@ -155,15 +155,15 @@ public void createHangupNotification(ReactApplicationContext context, String cal
context,
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
);

PendingIntent hangupPendingIntent = PendingIntent.getBroadcast(
context,
0,
new Intent(Constants.ACTION_HANGUP_CALL)
.putExtra(Constants.INCOMING_CALL_NOTIFICATION_ID, Constants.HANGUP_NOTIFICATION_ID),
PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
);

Bundle extras = new Bundle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.Context;
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.os.Build;

import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
Expand All @@ -37,10 +36,7 @@
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;

import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.InstanceIdResult;

import com.twilio.audioswitch.AudioDevice;
import com.twilio.audioswitch.AudioSwitch;
Expand Down Expand Up @@ -693,22 +689,18 @@ public void unregister(Promise promise) {

private void unregisterForCallInvites() {
FirebaseInstanceId.getInstance().getInstanceId()
.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
@Override
public void onComplete(@NonNull Task<InstanceIdResult> task) {
if (!task.isSuccessful()) {
Log.w(TAG, "FCM unregistration failed", task.getException());
return;
}

// Get new Instance ID token
String fcmToken = task.getResult().getToken();
if (fcmToken != null) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "Unregistering with FCM");
}
Voice.unregister(accessToken, Voice.RegistrationChannel.FCM, fcmToken, unregistrationListener);
.addOnCompleteListener(task -> {
if (!task.isSuccessful()) {
Log.w(TAG, "FCM unregistration failed", task.getException());
return;
}
// Get new Instance ID token
String fcmToken = task.getResult().getToken();
if (fcmToken != null) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "Unregistering with FCM");
}
Voice.unregister(accessToken, Voice.RegistrationChannel.FCM, fcmToken, unregistrationListener);
}
});
}
Expand Down

0 comments on commit 47a926a

Please sign in to comment.