From d1b921f4f07b9829b7799f169f3abeb8873e2f90 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 28 Aug 2019 10:21:46 +0200 Subject: [PATCH] Fixed missing chat notifications --- .../notifications/NotificationsManager.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/linphone/notifications/NotificationsManager.java b/app/src/main/java/org/linphone/notifications/NotificationsManager.java index 32551cd42..3a4b897e1 100644 --- a/app/src/main/java/org/linphone/notifications/NotificationsManager.java +++ b/app/src/main/java/org/linphone/notifications/NotificationsManager.java @@ -62,7 +62,6 @@ import org.linphone.utils.MediaScannerListener; public class NotificationsManager { private static final int SERVICE_NOTIF_ID = 1; private static final int MISSED_CALLS_NOTIF_ID = 2; - private static final int IN_APP_NOTIF_ID = 3; private final Context mContext; private final NotificationManager mNM; @@ -215,7 +214,20 @@ public class NotificationsManager { } public void destroy() { - mNM.cancelAll(); + // mNM.cancelAll(); + // Don't use cancelAll to keep message notifications ! + // When a message is received by a push, it will create a LinphoneService + // but it might be getting killed quite quickly after that + // causing the notification to be missed by the user... + + if (mCurrentForegroundServiceNotification > 0) { + mNM.cancel(mCurrentForegroundServiceNotification); + } + + for (Notifiable notifiable : mCallNotifMap.values()) { + mNM.cancel(notifiable.getNotificationId()); + } + Core core = LinphoneManager.getCore(); if (core != null) { core.removeListener(mListener);