diff --git a/android/app/src/main/java/com/mattermost/helpers/CustomPushNotificationHelper.java b/android/app/src/main/java/com/mattermost/helpers/CustomPushNotificationHelper.java index 1b072047ff..a8a33fbeac 100644 --- a/android/app/src/main/java/com/mattermost/helpers/CustomPushNotificationHelper.java +++ b/android/app/src/main/java/com/mattermost/helpers/CustomPushNotificationHelper.java @@ -182,7 +182,7 @@ public class CustomPushNotificationHelper { setNotificationGroup(notification, groupId, createSummary); setNotificationBadgeType(notification); - setNotificationChannel(notification, bundle); + setNotificationChannel(context, notification, bundle); setNotificationDeleteIntent(context, notification, bundle, notificationId); addNotificationReplyAction(context, notification, bundle, notificationId); @@ -365,12 +365,15 @@ public class CustomPushNotificationHelper { } } - private static void setNotificationChannel(NotificationCompat.Builder notification, Bundle bundle) { + private static void setNotificationChannel(Context context, NotificationCompat.Builder notification, Bundle bundle) { // If Android Oreo or above we need to register a channel if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { return; } + if (mHighImportanceChannel == null) { + createNotificationChannels(context); + } NotificationChannel notificationChannel = mHighImportanceChannel; notification.setChannelId(notificationChannel.getId()); } diff --git a/android/app/src/main/java/com/mattermost/helpers/NotificationHelper.java b/android/app/src/main/java/com/mattermost/helpers/NotificationHelper.java index a77eede9fd..2c53ce9660 100644 --- a/android/app/src/main/java/com/mattermost/helpers/NotificationHelper.java +++ b/android/app/src/main/java/com/mattermost/helpers/NotificationHelper.java @@ -145,9 +145,9 @@ public class NotificationHelper { for (final StatusBarNotification status : statusNotifications) { Bundle bundle = status.getNotification().extras; if (isThreadNotification) { - hasMore = bundle.getString("root_id").equals(rootId); + hasMore = bundle.containsKey("root_id") && bundle.getString("root_id").equals(rootId); } else { - hasMore = bundle.getString("channel_id").equals(channelId); + hasMore = bundle.containsKey("channel_id") && bundle.getString("channel_id").equals(channelId); } if (hasMore) break; } diff --git a/android/app/src/main/java/com/mattermost/rnbeta/CustomPushNotification.java b/android/app/src/main/java/com/mattermost/rnbeta/CustomPushNotification.java index ea95fb38bc..89a4edd9cd 100644 --- a/android/app/src/main/java/com/mattermost/rnbeta/CustomPushNotification.java +++ b/android/app/src/main/java/com/mattermost/rnbeta/CustomPushNotification.java @@ -31,7 +31,6 @@ public class CustomPushNotification extends PushNotification { public CustomPushNotification(Context context, Bundle bundle, AppLifecycleFacade appLifecycleFacade, AppLaunchHelper appLaunchHelper, JsIOHelper jsIoHelper) { super(context, bundle, appLifecycleFacade, appLaunchHelper, jsIoHelper); - CustomPushNotificationHelper.createNotificationChannels(context); dataHelper = new PushNotificationDataHelper(context); try {