Closed sushantsi closed 1 year ago
I had this issue as well when building against Android 33
buildToolsVersion = "33.0.1"
compileSdkVersion = 33
targetSdkVersion = 33
Here's the patch I'm using for @twilio/voice-react-native-sdk
that adds FLAG_IMMUTABLE
to the PendingIntent
s:
(please ignore the Java version change in the patch, I seem to need it on my codebase but it is not related to the PendingIntent
issue)
diff --git a/node_modules/@twilio/voice-react-native-sdk/android/build.gradle b/node_modules/@twilio/voice-react-native-sdk/android/build.gradle
index cacc775..1d272dc 100644
--- a/node_modules/@twilio/voice-react-native-sdk/android/build.gradle
+++ b/node_modules/@twilio/voice-react-native-sdk/android/build.gradle
@@ -1,7 +1,7 @@
buildscript {
ext.versions = [
- 'java' : JavaVersion.VERSION_11,
+ 'java' : JavaVersion.VERSION_1_8,
'androidGradlePlugin': '7.2.1',
'googleServices' : '4.3.10',
'voiceAndroid' : '6.1.3',
diff --git a/node_modules/@twilio/voice-react-native-sdk/android/src/main/java/com/twiliovoicereactnative/NotificationUtility.java b/node_modules/@twilio/voice-react-native-sdk/android/src/main/java/com/twiliovoicereactnative/NotificationUtility.java
index 4571868..b8f0a8f 100644
--- a/node_modules/@twilio/voice-react-native-sdk/android/src/main/java/com/twiliovoicereactnative/NotificationUtility.java
+++ b/node_modules/@twilio/voice-react-native-sdk/android/src/main/java/com/twiliovoicereactnative/NotificationUtility.java
@@ -46,14 +46,14 @@ public class NotificationUtility {
rejectIntent.putExtra(Constants.INCOMING_CALL_INVITE, callInvite);
rejectIntent.putExtra(Constants.NOTIFICATION_ID, notificationId);
rejectIntent.putExtra(Constants.UUID, uuid);
- PendingIntent piRejectIntent = PendingIntent.getService(context.getApplicationContext(), 0, rejectIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent piRejectIntent = PendingIntent.getService(context.getApplicationContext(), 0, rejectIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
Intent acceptIntent = new Intent(context.getApplicationContext(), IncomingCallNotificationService.class);
acceptIntent.setAction(Constants.ACTION_ACCEPT);
acceptIntent.putExtra(Constants.INCOMING_CALL_INVITE, callInvite);
acceptIntent.putExtra(Constants.NOTIFICATION_ID, notificationId);
acceptIntent.putExtra(Constants.UUID, uuid);
- PendingIntent piAcceptIntent = PendingIntent.getService(context.getApplicationContext(), 0, acceptIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent piAcceptIntent = PendingIntent.getService(context.getApplicationContext(), 0, acceptIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
Bitmap icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_call_end_white_24dp);
String title = getDisplayName(callInvite);
@@ -66,7 +66,7 @@ public class NotificationUtility {
remoteViews.setOnClickPendingIntent(R.id.button_decline, piRejectIntent);
Intent notification_intent = new Intent(context.getApplicationContext(), IncomingCallNotificationService.class);
- PendingIntent pendingIntent = PendingIntent.getActivity(context.getApplicationContext(), 0, notification_intent, 0);
+ PendingIntent pendingIntent = PendingIntent.getActivity(context.getApplicationContext(), 0, notification_intent, PendingIntent.FLAG_IMMUTABLE);
remoteViews.setOnClickPendingIntent(R.id.notification, pendingIntent);
@@ -123,7 +123,7 @@ public class NotificationUtility {
notification_intent.setAction(Constants.ACTION_PUSH_APP_TO_FOREGROUND);
notification_intent.putExtra(Constants.NOTIFICATION_ID, notificationId);
notification_intent.putExtra(Constants.UUID, uuid);
- PendingIntent pendingIntent = PendingIntent.getService(context.getApplicationContext(), 0, notification_intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent pendingIntent = PendingIntent.getService(context.getApplicationContext(), 0, notification_intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
remoteViews.setOnClickPendingIntent(R.id.tap_to_app, pendingIntent);
@@ -133,7 +133,7 @@ public class NotificationUtility {
endCallIntent.setAction(Constants.ACTION_CALL_DISCONNECT);
endCallIntent.putExtra(Constants.NOTIFICATION_ID, notificationId);
endCallIntent.putExtra(Constants.UUID, uuid);
- PendingIntent piEndCallIntent = PendingIntent.getService(context.getApplicationContext(), 0, endCallIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent piEndCallIntent = PendingIntent.getService(context.getApplicationContext(), 0, endCallIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
remoteViews.setOnClickPendingIntent(R.id.end_call, piEndCallIntent);
@@ -187,7 +187,7 @@ public class NotificationUtility {
notification_intent.setAction(Constants.ACTION_PUSH_APP_TO_FOREGROUND);
notification_intent.putExtra(Constants.NOTIFICATION_ID, notificationId);
notification_intent.putExtra(Constants.UUID, uuid);
- PendingIntent pendingIntent = PendingIntent.getService(context.getApplicationContext(), 0, notification_intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent pendingIntent = PendingIntent.getService(context.getApplicationContext(), 0, notification_intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
remoteViews.setOnClickPendingIntent(R.id.tap_to_app, pendingIntent);
@@ -196,7 +196,7 @@ public class NotificationUtility {
endCallIntent.setAction(Constants.ACTION_CALL_DISCONNECT);
endCallIntent.putExtra(Constants.NOTIFICATION_ID, notificationId);
endCallIntent.putExtra(Constants.UUID, uuid);
- PendingIntent piEndCallIntent = PendingIntent.getService(context.getApplicationContext(), 0, endCallIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent piEndCallIntent = PendingIntent.getService(context.getApplicationContext(), 0, endCallIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
remoteViews.setOnClickPendingIntent(R.id.end_call, piEndCallIntent);
@@ -248,7 +248,7 @@ public class NotificationUtility {
notification_intent.setAction(Constants.ACTION_PUSH_APP_TO_FOREGROUND);
notification_intent.putExtra(Constants.NOTIFICATION_ID, notificationId);
notification_intent.putExtra(Constants.UUID, uuid);
- PendingIntent pendingIntent = PendingIntent.getService(context.getApplicationContext(), 0, notification_intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent pendingIntent = PendingIntent.getService(context.getApplicationContext(), 0, notification_intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
remoteViews.setOnClickPendingIntent(R.id.tap_to_app, pendingIntent);
@@ -257,7 +257,7 @@ public class NotificationUtility {
endCallIntent.setAction(Constants.ACTION_CALL_DISCONNECT);
endCallIntent.putExtra(Constants.NOTIFICATION_ID, notificationId);
endCallIntent.putExtra(Constants.UUID, uuid);
- PendingIntent piEndCallIntent = PendingIntent.getService(context.getApplicationContext(), 0, endCallIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent piEndCallIntent = PendingIntent.getService(context.getApplicationContext(), 0, endCallIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
remoteViews.setOnClickPendingIntent(R.id.end_call, piEndCallIntent);
Thanks for reaching out @sushantsi, and @se1exin for providing a fix for the issue. Can you confirm that this solves your problem @sushantsi?
Hey hi, @mhuynh5757, @se1exin it's worked now, and the application is not crashing. Thank you @se1exin @mhuynh5757
after adding services to the Android manifest, the application is crashing on outgoing call.