clear notifications on message read
Signed-off-by: Michele Balistreri <michele@bitgamma.com>
This commit is contained in:
parent
a569687161
commit
8c493510a4
|
@ -117,6 +117,13 @@ public class PushNotification extends ReactContextBaseJavaModule implements Acti
|
||||||
pushNotificationHelper.sendToNotificationCentre(bundle);
|
pushNotificationHelper.sendToNotificationCentre(bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ReactMethod
|
||||||
|
public void clearMessageNotifications(String conversationId) {
|
||||||
|
if (this.started) {
|
||||||
|
pushNotificationHelper.clearMessageNotifications(conversationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void enableNotifications() {
|
public void enableNotifications() {
|
||||||
this.started = true;
|
this.started = true;
|
||||||
|
|
|
@ -119,13 +119,9 @@ public class PushNotificationHelper {
|
||||||
context.startActivity(getOpenAppIntent(deepLink));
|
context.startActivity(getOpenAppIntent(deepLink));
|
||||||
}
|
}
|
||||||
if (groupId != null) {
|
if (groupId != null) {
|
||||||
removeGroup(groupId);
|
cleanGroup(groupId);
|
||||||
// clean up the group notifications when there is no
|
|
||||||
// more unread chats
|
|
||||||
if (messageGroups.size() == 0) {
|
|
||||||
notificationManager.cancelAll();
|
|
||||||
}}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (intent.getAction() == ACTION_TAP_STOP) {
|
if (intent.getAction() == ACTION_TAP_STOP) {
|
||||||
stop();
|
stop();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
@ -190,6 +186,11 @@ public class PushNotificationHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearMessageNotifications(String conversationId) {
|
||||||
|
notificationManager.cancel(conversationId.hashCode());
|
||||||
|
cleanGroup(conversationId);
|
||||||
|
}
|
||||||
|
|
||||||
public void sendToNotificationCentreWithPicture(final Bundle bundle, Bitmap largeIconBitmap, Bitmap bigPictureBitmap) {
|
public void sendToNotificationCentreWithPicture(final Bundle bundle, Bitmap largeIconBitmap, Bitmap bigPictureBitmap) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -823,6 +824,13 @@ public class PushNotificationHelper {
|
||||||
this.messageGroups.remove(groupId);
|
this.messageGroups.remove(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void cleanGroup(String groupId) {
|
||||||
|
removeGroup(groupId);
|
||||||
|
if (messageGroups.size() == 0) {
|
||||||
|
notificationManager.cancelAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
Log.e(LOG_TAG, "Starting Foreground Service");
|
Log.e(LOG_TAG, "Starting Foreground Service");
|
||||||
Intent serviceIntent = new Intent(context, ForegroundService.class);
|
Intent serviceIntent = new Intent(context, ForegroundService.class);
|
||||||
|
|
|
@ -65,7 +65,8 @@
|
||||||
(fx/defn handle-mark-all-read
|
(fx/defn handle-mark-all-read
|
||||||
{:events [:chat.ui/mark-all-read-pressed :chat/mark-all-as-read]}
|
{:events [:chat.ui/mark-all-read-pressed :chat/mark-all-as-read]}
|
||||||
[_ chat-id]
|
[_ chat-id]
|
||||||
{::json-rpc/call [{:method (json-rpc/call-ext-method "markAllRead")
|
{:clear-message-notifications chat-id
|
||||||
|
::json-rpc/call [{:method (json-rpc/call-ext-method "markAllRead")
|
||||||
:params [chat-id]
|
:params [chat-id]
|
||||||
:on-success #(re-frame/dispatch [::mark-all-read-successful chat-id])}]})
|
:on-success #(re-frame/dispatch [::mark-all-read-successful chat-id])}]})
|
||||||
|
|
||||||
|
|
|
@ -129,8 +129,8 @@
|
||||||
{:db db
|
{:db db
|
||||||
:utils/dispatch-later
|
:utils/dispatch-later
|
||||||
(concat [{:ms 20 :dispatch [:process-response response-js]}]
|
(concat [{:ms 20 :dispatch [:process-response response-js]}]
|
||||||
(when-let [chat-id (:current-chat-id db)]
|
(when (and (:current-chat-id db) (= "active" (:app-state db)))
|
||||||
[{:ms 100 :dispatch [:chat/mark-all-as-read chat-id]}])
|
[{:ms 100 :dispatch [:chat/mark-all-as-read (:current-chat-id db)]}])
|
||||||
(when (seq senders)
|
(when (seq senders)
|
||||||
[{:ms 100 :dispatch [:chat/add-senders-to-chat-users (vals senders)]}]))}))
|
[{:ms 100 :dispatch [:chat/add-senders-to-chat-users (vals senders)]}]))}))
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,8 @@
|
||||||
(mailserver/process-next-messages-request)
|
(mailserver/process-next-messages-request)
|
||||||
(wallet/restart-wallet-service-after-background app-in-background-since)
|
(wallet/restart-wallet-service-after-background app-in-background-since)
|
||||||
(universal-links/process-stored-event)
|
(universal-links/process-stored-event)
|
||||||
|
#(when-let [chat-id (:current-chat-id db)]
|
||||||
|
{:dispatch [:chat/mark-all-as-read chat-id]})
|
||||||
#(when requires-bio-auth
|
#(when requires-bio-auth
|
||||||
(biometric/authenticate % on-biometric-auth-result authentication-options)))))
|
(biometric/authenticate % on-biometric-auth-result authentication-options)))))
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
(defn present-local-notification [opts]
|
(defn present-local-notification [opts]
|
||||||
(.presentLocalNotification ^js (pn-android) (clj->js opts)))
|
(.presentLocalNotification ^js (pn-android) (clj->js opts)))
|
||||||
|
|
||||||
|
(defn clear-message-notifications [chat-id]
|
||||||
|
(.clearMessageNotifications ^js (pn-android) chat-id))
|
||||||
|
|
||||||
(defn create-channel [{:keys [channel-id channel-name]}]
|
(defn create-channel [{:keys [channel-id channel-name]}]
|
||||||
(.createChannel ^js (pn-android)
|
(.createChannel ^js (pn-android)
|
||||||
#js {:channelId channel-id
|
#js {:channelId channel-id
|
||||||
|
|
|
@ -86,6 +86,12 @@
|
||||||
(pn-android/disable-notifications)
|
(pn-android/disable-notifications)
|
||||||
(.abandonPermissions ^js pn-ios))))
|
(.abandonPermissions ^js pn-ios))))
|
||||||
|
|
||||||
|
(re-frame/reg-fx
|
||||||
|
:clear-message-notifications
|
||||||
|
(fn [chat-id]
|
||||||
|
(when platform/android?
|
||||||
|
(pn-android/clear-message-notifications chat-id))))
|
||||||
|
|
||||||
(fx/defn handle-enable-notifications-event
|
(fx/defn handle-enable-notifications-event
|
||||||
{:events [::registered-for-push-notifications]}
|
{:events [::registered-for-push-notifications]}
|
||||||
[cofx token]
|
[cofx token]
|
||||||
|
|
Loading…
Reference in New Issue