diff --git a/OneSignalSDK/onesignal/src/main/java/com/onesignal/NotificationOpenedProcessor.java b/OneSignalSDK/onesignal/src/main/java/com/onesignal/NotificationOpenedProcessor.java index 756fa8f593..5dcb935b84 100644 --- a/OneSignalSDK/onesignal/src/main/java/com/onesignal/NotificationOpenedProcessor.java +++ b/OneSignalSDK/onesignal/src/main/java/com/onesignal/NotificationOpenedProcessor.java @@ -27,6 +27,9 @@ package com.onesignal; +import static com.onesignal.GenerateNotification.BUNDLE_KEY_ANDROID_NOTIFICATION_ID; +import static com.onesignal.GenerateNotification.BUNDLE_KEY_ONESIGNAL_DATA; + import android.app.Activity; import android.app.NotificationManager; import android.content.ContentValues; @@ -44,9 +47,6 @@ import org.json.JSONException; import org.json.JSONObject; -import static com.onesignal.GenerateNotification.BUNDLE_KEY_ANDROID_NOTIFICATION_ID; -import static com.onesignal.GenerateNotification.BUNDLE_KEY_ONESIGNAL_DATA; - // Process both notifications opens and dismisses. class NotificationOpenedProcessor { @@ -74,7 +74,13 @@ private static void handleDismissFromActionButtonPress(Context context, Intent i // Pressed an action button, need to clear the notification and close the notification area manually. if (intent.getBooleanExtra("action_button", false)) { NotificationManagerCompat.from(context).cancel(intent.getIntExtra(BUNDLE_KEY_ANDROID_NOTIFICATION_ID, 0)); - context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); + + //Close notification drawer user override targetSdkVersion to be lower than Android 11 + // See https://developer.android.com/about/versions/12/behavior-changes-all#close-system-dialogs + int targetSdkVersion = context.getApplicationContext().getApplicationInfo().targetSdkVersion; + if (targetSdkVersion < Build.VERSION_CODES.S ) { + context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); + } } }