Fix notification channel creation

This commit is contained in:
Mario Danic 2018-11-07 14:29:07 +01:00
parent a90ba05d29
commit 65d9296209
2 changed files with 6 additions and 3 deletions

View File

@ -304,7 +304,7 @@ public class NotificationWorker extends Worker {
groupName);
if (decryptedPushMessage.getType().equals("chat")) {
NotificationUtils.createNotificationChannel(notificationManager,
NotificationUtils.createNotificationChannel(context,
NotificationUtils.NOTIFICATION_CHANNEL_MESSAGES_V3, context.getResources()
.getString(R.string.nc_notification_channel_messages), context.getResources()
.getString(R.string.nc_notification_channel_messages), true,
@ -312,7 +312,7 @@ public class NotificationWorker extends Worker {
notificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_MESSAGES_V3);
} else {
NotificationUtils.createNotificationChannel(notificationManager,
NotificationUtils.createNotificationChannel(context,
NotificationUtils.NOTIFICATION_CHANNEL_CALLS_V3, context.getResources()
.getString(R.string.nc_notification_channel_calls), context.getResources()
.getString(R.string.nc_notification_channel_calls_description), true,

View File

@ -44,11 +44,14 @@ public class NotificationUtils {
public static final String NOTIFICATION_CHANNEL_CALLS_V3 = "NOTIFICATION_CHANNEL_CALLS_V3";
@TargetApi(Build.VERSION_CODES.O)
public static void createNotificationChannel(NotificationManager notificationManager,
public static void createNotificationChannel(Context context,
String channelId, String channelName,
String channelDescription, boolean enableLights,
int importance) {
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O
&& notificationManager.getNotificationChannel(channelId) == null) {