diff --git a/pushsdk/build.gradle b/pushsdk/build.gradle index 60be10f..3985237 100644 --- a/pushsdk/build.gradle +++ b/pushsdk/build.gradle @@ -33,7 +33,7 @@ afterEvaluate { maven(MavenPublication) { groupId = 'com.github.shadowalker77' artifactId = 'pushnotification' - version = '1.1.6' + version = '1.1.7' from components.release } diff --git a/pushsdk/src/main/java/ir/ayantech/pushsdk/helper/NotificationUtils.java b/pushsdk/src/main/java/ir/ayantech/pushsdk/helper/NotificationUtils.java index a33124b..4fab64a 100644 --- a/pushsdk/src/main/java/ir/ayantech/pushsdk/helper/NotificationUtils.java +++ b/pushsdk/src/main/java/ir/ayantech/pushsdk/helper/NotificationUtils.java @@ -72,27 +72,21 @@ public static void showNotificationMessage(final Context context, + "://" + context.getPackageName() + "/raw/notification"); // if (!TextUtils.isEmpty(bigIconUrl)) { // if (bigIconUrl.length() > 4 && Patterns.WEB_URL.matcher(bigIconUrl).matches()) { - ImageHelper.downloadImage(bigIconUrl, new ImageHelper.OnBitmapDownloaded() { - @Override - public void onBitmapDownloaded(final Bitmap bigIcon) { - if (imageUrl != null) { - ImageHelper.downloadImage(imageUrl, new ImageHelper.OnBitmapDownloaded() { - @Override - public void onBitmapDownloaded(Bitmap bitmap) { - if (isCustom) - showCustomNotification(context, bitmap, mBuilder, icon, title, message, resultPendingIntent, alarmSound, buttonList, bigIcon); - else if (bitmap != null) - showBigNotification(context, bitmap, mBuilder, icon, title, message, resultPendingIntent, alarmSound, buttonList, bigIcon); - else - showSmallNotification(mBuilder, context, icon, title, message, resultPendingIntent, alarmSound, buttonList, bigIcon); - } - }); - } else { + ImageHelper.downloadImage(bigIconUrl, bigIcon -> { + if (imageUrl != null) { + ImageHelper.downloadImage(imageUrl, bitmap -> { if (isCustom) - showCustomNotification(context, null, mBuilder, icon, title, message, resultPendingIntent, alarmSound, buttonList, bigIcon); + showCustomNotification(context, bitmap, mBuilder, icon, title, message, resultPendingIntent, alarmSound, buttonList, bigIcon); + else if (bitmap != null) + showBigNotification(context, bitmap, mBuilder, icon, title, message, resultPendingIntent, alarmSound, buttonList, bigIcon); else showSmallNotification(mBuilder, context, icon, title, message, resultPendingIntent, alarmSound, buttonList, bigIcon); - } + }); + } else { + if (isCustom) + showCustomNotification(context, null, mBuilder, icon, title, message, resultPendingIntent, alarmSound, buttonList, bigIcon); + else + showSmallNotification(mBuilder, context, icon, title, message, resultPendingIntent, alarmSound, buttonList, bigIcon); } }); // } @@ -265,11 +259,16 @@ public static void playNotificationSound(Context context) { } private static PendingIntent getPendingIntentByMessage(Context context, Message message) { + int flags; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) + flags = PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE; + else + flags = PendingIntent.FLAG_CANCEL_CURRENT; return PendingIntent.getActivity( context, new Random().nextInt(1000), IncomeMessageActivity.getIntentByMessage(context, message), - PendingIntent.FLAG_CANCEL_CURRENT + flags ); }