Skip to content

Commit b937465

Browse files
authored
Merge pull request #1548 from vincent-paing/fix/close_system_dialog_crash
Fix Crash when tapping on Notification action button in Android 12
2 parents 603b0de + c9f048d commit b937465

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/NotificationOpenedProcessor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ private static void handleDismissFromActionButtonPress(Context context, Intent i
7474
// Pressed an action button, need to clear the notification and close the notification area manually.
7575
if (intent.getBooleanExtra("action_button", false)) {
7676
NotificationManagerCompat.from(context).cancel(intent.getIntExtra(BUNDLE_KEY_ANDROID_NOTIFICATION_ID, 0));
77-
context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
77+
78+
// Only close the notifications shade on Android versions where it is allowed, Android 11 and lower.
79+
// See https://developer.android.com/about/versions/12/behavior-changes-all#close-system-dialogs
80+
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.S) {
81+
context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
82+
}
7883
}
7984
}
8085

0 commit comments

Comments
 (0)