Skip to content

Commit e105cac

Browse files
committed
fix: Android 12 crash on closing notification drawer
See: #1543
1 parent ac8c2a7 commit e105cac

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ 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+
//Close notification drawer user override targetSdkVersion to be lower than Android 11
79+
// See https://developer.android.com/about/versions/12/behavior-changes-all#close-system-dialogs
80+
int targetSdkVersion = context.getApplicationContext().getApplicationInfo().targetSdkVersion;
81+
if (targetSdkVersion < Build.VERSION_CODES.S ) {
82+
context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
83+
}
7884
}
7985
}
8086

0 commit comments

Comments
 (0)