Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

[BUG] Push notifications are not sent to mobile if a desktop session is open

Open Alhrath opened this issue 9 years ago • 11 comments

Description

If I leave my desktop app connected, even in away or busy status, the push notifications are not sent to my mobile, connected to the same account. I understood it is intended if status is online, but not with other status.

Server Setup Information:

  • Version of Rocket.Chat Server: 0.59.0-rc.13
  • Operating System: Debian 9
  • Deployment Method: Docker
  • Number of Running Instances: 1 (?)
  • DB Replicaset Oplog: disabled
  • Node Version: 4.8.4
  • Push gateway : https://gateway.rocket.chat

Client Setup Information:

  • Desktop app : rocket.chat+ 2.9.0 on linux
  • Mobile app : rocket.chat+ 1.0.21-DEBUG
  • Device model : Galaxy A3 - Android 6.0.1

Steps to Reproduce:

  1. Connect to your server with your mobile phone
  2. Connect to your server with your desktop app
  3. Wait for a message or a mention
  4. The notification is given to your desktop app but not to your mobile phone

Expected behavior:

Push notifications should be sent to mobile, at least when desktop connexion is in away status.

Actual behavior:

Push notifications are never sent if a desktop session is open. They are if the mobile session is the only one open.

Relevant logs:

Log when desktop app is NOT connected (push notification sent) :


I20171014-12:51:48.698(0) Meteor ➔ method stream-notify-room -> userId: pW7K8cN57FkwNz648 , arguments:  { '0': 'GENERAL/typing', '1': 'Nietzsche', '2': true } 
I20171014-12:51:50.272(0) Meteor ➔ method spotlight -> userId: pW7K8cN57FkwNz648 , arguments:  { '0': 'a',   '1': [ 'admin', 'Alhrath', 'rocket.cat' ],   '2': { users: true },   '3': 'GENERAL' } 
I20171014-12:51:51.327(0) Meteor ➔ method spotlight -> userId: pW7K8cN57FkwNz648 , arguments:  { '0': 'al',   '1': [ 'Alhrath' ],   '2': { users: true },   '3': 'GENERAL' } 
I20171014-12:51:51.786(0) Meteor ➔ method spotlight -> userId: pW7K8cN57FkwNz648 , arguments:  { '0': 'alh',   '1': [ 'Alhrath' ],   '2': { users: true },   '3': 'GENERAL' } 
I20171014-12:51:53.366(0) Meteor ➔ method stream-notify-room -> userId: pW7K8cN57FkwNz648 , arguments:  { '0': 'GENERAL/typing', '1': 'Nietzsche', '2': false } 
I20171014-12:51:53.373(0) Meteor ➔ method sendMessage -> userId: pW7K8cN57FkwNz648 , arguments:  { '0': { _id: 'EEciuMLgsHJbp4kLF', rid: 'GENERAL', msg: '@Alhrath ' } } 
I20171014-12:51:53.375(0) Meteor ➔ method canAccessRoom -> userId: pW7K8cN57FkwNz648 , arguments:  { '0': 'GENERAL', '1': 'pW7K8cN57FkwNz648' } 
I20171014-12:51:53.414(0) Integrations ➔ Outgoing WebHook.debug Execute Trigger: sendMessage 
I20171014-12:51:53.416(0) Integrations ➔ Outgoing WebHook.debug Got the event arguments for the event: sendMessage { event: 'sendMessage',   message:     { _id: 'EEciuMLgsHJbp4kLF',      rid: 'GENERAL',      msg: '@Alhrath ',      ts: Sat Oct 14 2017 12:51:53 GMT+0000 (UTC),      u:        { _id: 'pW7K8cN57FkwNz648',         username: 'Nietzsche',         name: 'Nietzsche' },      mentions: [ [Object] ],      channels: [],      _updatedAt: Sat Oct 14 2017 12:51:53 GMT+0000 (UTC),      sandstormSessionId: null },   room:     { _id: 'GENERAL',      ts: Fri Oct 13 2017 18:58:13 GMT+0000 (UTC),      t: 'c',      name: 'general',      msgs: 12,      default: true,      _updatedAt: Sat Oct 14 2017 12:47:41 GMT+0000 (UTC),      lm: Sat Oct 14 2017 11:38:35 GMT+0000 (UTC),      meta:        { revision: 10,         created: 1507979899887,         version: 0,         updated: 1507985261314 },      '$loki': 1,      username: 'Nietzsche',      usernames: [ 'Nietzsche', 'Alhrath', 'admin' ] } } 
I20171014-12:51:53.417(0) Integrations ➔ Outgoing WebHook.debug Starting search for triggers for the room: GENERAL 
I20171014-12:51:53.417(0) Integrations ➔ Outgoing WebHook.debug Found 0 to iterate over and see if the match the event. 
I20171014-12:51:54.039(0) Push: send message "#general" via query { userId: '4HMTei6gZLPch3TRp' } 
I20171014-12:51:54.042(0) Push: send to token { gcm: 'dyZQbw8T1Qg:APA91bGLyhC18GXCArzatJmLP5Xx-W5gNAatKorNMnzQi6bchEODnot3DmrKU5CkAWIXf0md-3GnVlrZYcr5hhh8U9g0rHY1_RQGcNnmh6dmxv-vq1xNbJe-iLdkP7Gg8PEKK-zrfQmb' } 
I20171014-12:51:55.922(0) Meteor ➔ method spotlight -> userId: mgpsxDZJQtnuFEQHr , arguments:  { '0': 'alh',   '1': [ 'Alhrath' ],   '2': { users: true },   '3': 'GENERAL' } 
I20171014-12:52:02.040(0) Meteor ➔ method readMessages -> userId: mgpsxDZJQtnuFEQHr , arguments:  { '0': 'GENERAL' }  

Log when desktop app is connected with away status (push notification not sent) :


I20171014-12:56:31.223(0) Meteor ➔ method stream-notify-room -> userId: pW7K8cN57FkwNz648 , arguments:  { '0': 'GENERAL/typing', '1': 'Nietzsche', '2': true } 
I20171014-12:56:32.203(0) Meteor ➔ method spotlight -> userId: pW7K8cN57FkwNz648 , arguments:  { '0': 'alh',   '1': [ 'Alhrath' ],   '2': { users: true },   '3': 'GENERAL' } 
I20171014-12:56:34.012(0) Meteor ➔ method stream-notify-room -> userId: pW7K8cN57FkwNz648 , arguments:  { '0': 'GENERAL/typing', '1': 'Nietzsche', '2': false } 
I20171014-12:56:34.016(0) Meteor ➔ method sendMessage -> userId: pW7K8cN57FkwNz648 , arguments:  { '0': { _id: 'N6EgHYJYknPmNFdmk', rid: 'GENERAL', msg: '@Alhrath ' } } 
I20171014-12:56:34.018(0) Meteor ➔ method canAccessRoom -> userId: pW7K8cN57FkwNz648 , arguments:  { '0': 'GENERAL', '1': 'pW7K8cN57FkwNz648' } 
I20171014-12:56:34.043(0) Integrations ➔ Outgoing WebHook.debug Execute Trigger: sendMessage 
I20171014-12:56:34.045(0) Integrations ➔ Outgoing WebHook.debug Got the event arguments for the event: sendMessage { event: 'sendMessage',   message:     { _id: 'N6EgHYJYknPmNFdmk',      rid: 'GENERAL',      msg: '@Alhrath ',      ts: Sat Oct 14 2017 12:56:34 GMT+0000 (UTC),      u:        { _id: 'pW7K8cN57FkwNz648',         username: 'Nietzsche',         name: 'Nietzsche' },      mentions: [ [Object] ],      channels: [],      _updatedAt: Sat Oct 14 2017 12:56:34 GMT+0000 (UTC),      sandstormSessionId: null },   room:     { _id: 'GENERAL',      ts: Fri Oct 13 2017 18:58:13 GMT+0000 (UTC),      t: 'c',      name: 'general',      msgs: 13,      default: true,      _updatedAt: Sat Oct 14 2017 12:51:53 GMT+0000 (UTC),      lm: Sat Oct 14 2017 12:51:53 GMT+0000 (UTC),      meta:        { revision: 11,         created: 1507979899887,         version: 0,         updated: 1507985513394 },      '$loki': 1,      username: 'Nietzsche',      usernames: [ 'Nietzsche', 'admin', 'Alhrath' ] } } 
I20171014-12:56:34.047(0) Integrations ➔ Outgoing WebHook.debug Starting search for triggers for the room: GENERAL 
I20171014-12:56:34.047(0) Integrations ➔ Outgoing WebHook.debug Found 0 to iterate over and see if the match the event. 
I20171014-12:56:34.276(0) Meteor ➔ method spotlight -> userId: mgpsxDZJQtnuFEQHr , arguments:  { '0': 'alh',   '1': [ 'Alhrath' ],   '2': { users: true },   '3': 'GENERAL' } 
I20171014-12:56:37.763(0) Meteor ➔ method readMessages -> userId: mgpsxDZJQtnuFEQHr , arguments:  { '0': 'GENERAL' }  

Alhrath avatar Oct 14 '17 13:10 Alhrath

Push notifications are not send, as long as the user status in the desktop is "online". This status fades away after 5 minutes. We have made this configurable with this PR https://github.com/RocketChat/Rocket.Chat/pull/8418

See also https://github.com/RocketChat/Rocket.Chat/issues/7130

rasos avatar Oct 17 '17 14:10 rasos

have same issue (version 0.59.1)

efih avatar Oct 23 '17 07:10 efih

@rasos Ok, I understand it more precisely now. I confirm that with both devices connected, the push notification will be sent to the mobile after 5 min of inactivity on the computer. A simple mouse move on the computer will reset the countdown, even if rocket chat is minimized on it. User status as defined by the user seems to have no effect on this.

In my opinion, it's quite confusing for user, especially if your computer can be used by someone else ...

Alhrath avatar Oct 23 '17 14:10 Alhrath

cannot choose push to both device ? pc and mobile app ?

efih avatar Oct 24 '17 10:10 efih

have same issue (version 0.59.2)

I wrote a temporary fix.

diff --git a/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js b/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js
index ddda8b880..8068dab73 100644
--- a/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js
+++ b/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js
@@ -275,7 +275,7 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room, userId) {
                }

                if ((userOfMention != null) && canBeNotified(userOfMentionId, 'desktop')) {
-                       if (Push.enabled === true && userOfMention.statusConnection !== 'online') {
+                       if (Push.enabled === true) {
                                RocketChat.PushNotification.send({
                                        roomId: message.rid,
                                        username: push_username,
@@ -332,9 +332,6 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room, userId) {
                        let usersOfMobileMentions = RocketChat.models.Users.find({
                                _id: {
                                        $in: mobileMentionIds
-                               },
-                               statusConnection: {
-                                       $ne:'online'
                                }
                        }, {
                                fields: {

tomcsi avatar Oct 30 '17 12:10 tomcsi

Version 0.59.3 I still have this issue with notifications not coming through to iOS devices. Any info that's needed I'll try and provide.

JoeArcher007 avatar Nov 06 '17 19:11 JoeArcher007

Well, I found out my issue. And I guess it didn't have to do with this one, so ignore if not the exact same.

It turned out the gateway had changed somehow in my config. The gateway for Push notifications was set to https://rocket.chat instead of https://gateway.rocket.chat

Hopefully that helps others maybe?

JoeArcher007 avatar Nov 09 '17 16:11 JoeArcher007

have same issue (version 0.59.3) as @Alhrath

Vacoi avatar Dec 05 '17 13:12 Vacoi

Why this is not fixed yet? The same issue on 1.1.0-develop. No push on mobile if desktop session is active... Please take a look at @sampaiodiego @ggazzo

devloper avatar May 21 '19 02:05 devloper

@devloper this is the expected behavior.

There is a setting though on Admin > General > Notifications where you can chose to send mobile notifications even if the user is online:

image

sampaiodiego avatar May 23 '19 13:05 sampaiodiego