Android: Avoid crash when clearing notifications (#1282)

This commit is contained in:
enahum
2017-12-07 12:19:42 -03:00
committed by GitHub
parent f2a02d7756
commit 76169720a5

View File

@@ -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);
}
}
}