From 0df647cedf0465fd0234d5d2ee80a2cf4196c841 Mon Sep 17 00:00:00 2001 From: jwfing Date: Thu, 9 Jun 2022 12:08:02 +0800 Subject: [PATCH] compatible for android 12 within leancloud push notification --- .../java/cn/leancloud/push/lite/AVNotificationManager.java | 3 ++- .../java/cn/leancloud/push/AndroidNotificationManager.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/android-sdk/leancloud-push-lite/src/main/java/cn/leancloud/push/lite/AVNotificationManager.java b/android-sdk/leancloud-push-lite/src/main/java/cn/leancloud/push/lite/AVNotificationManager.java index 2f229c51..b7b47f61 100644 --- a/android-sdk/leancloud-push-lite/src/main/java/cn/leancloud/push/lite/AVNotificationManager.java +++ b/android-sdk/leancloud-push-lite/src/main/java/cn/leancloud/push/lite/AVNotificationManager.java @@ -283,7 +283,8 @@ private void sendNotification(String from, String msg, Intent resultIntent) { ComponentName cn = new ComponentName(context, clsName); resultIntent.setComponent(cn); PendingIntent contentIntent = - PendingIntent.getActivity(context, notificationId, resultIntent, 0); + PendingIntent.getActivity(context, notificationId, resultIntent, + PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); String sound = getSound(msg); Notification notification = null; if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.N_MR1) { diff --git a/android-sdk/realtime-android/src/main/java/cn/leancloud/push/AndroidNotificationManager.java b/android-sdk/realtime-android/src/main/java/cn/leancloud/push/AndroidNotificationManager.java index 1a10179e..22505f5b 100644 --- a/android-sdk/realtime-android/src/main/java/cn/leancloud/push/AndroidNotificationManager.java +++ b/android-sdk/realtime-android/src/main/java/cn/leancloud/push/AndroidNotificationManager.java @@ -94,7 +94,8 @@ private void sendNotification(String from, String msg, Intent resultIntent) { ComponentName cn = new ComponentName(context, clsName); resultIntent.setComponent(cn); PendingIntent contentIntent = - PendingIntent.getActivity(context, notificationId, resultIntent, 0); + PendingIntent.getActivity(context, notificationId, resultIntent, + PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); String sound = getSound(msg); String title = getTitle(msg); String notificationChannel = getNotificationChannel(msg);