From 76169720a5a2eec04d52e491d4af566cdf3b4ff0 Mon Sep 17 00:00:00 2001 From: enahum Date: Thu, 7 Dec 2017 12:19:42 -0300 Subject: [PATCH] Android: Avoid crash when clearing notifications (#1282) --- .../java/com/mattermost/rnbeta/CustomPushNotification.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 98881b318..aa2d51f84 100644 --- a/android/app/src/main/java/com/mattermost/rnbeta/CustomPushNotification.java +++ b/android/app/src/main/java/com/mattermost/rnbeta/CustomPushNotification.java @@ -56,8 +56,10 @@ public class CustomPushNotification extends PushNotification { if (notificationId != -1) { channelIdToNotificationCount.remove(channelId); channelIdToNotification.remove(channelId); - final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - notificationManager.cancel(notificationId); + if (context != null) { + final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + notificationManager.cancel(notificationId); + } } }