[BUG] Push notifications are not sent to mobile if a desktop session is open
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:
- Connect to your server with your mobile phone
- Connect to your server with your desktop app
- Wait for a message or a mention
- 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) :
[34mI20171014-12:51:48.698(0) [34mMeteor ➔ method stream-notify-room -> userId: pW7K8cN57FkwNz648 , arguments: { '0': 'GENERAL/typing', '1': 'Nietzsche', '2': true }
[34mI20171014-12:51:50.272(0) [34mMeteor ➔ method spotlight -> userId: pW7K8cN57FkwNz648 , arguments: { '0': 'a', '1': [ 'admin', 'Alhrath', 'rocket.cat' ], '2': { users: true }, '3': 'GENERAL' }
[34mI20171014-12:51:51.327(0) [34mMeteor ➔ method spotlight -> userId: pW7K8cN57FkwNz648 , arguments: { '0': 'al', '1': [ 'Alhrath' ], '2': { users: true }, '3': 'GENERAL' }
[34mI20171014-12:51:51.786(0) [34mMeteor ➔ method spotlight -> userId: pW7K8cN57FkwNz648 , arguments: { '0': 'alh', '1': [ 'Alhrath' ], '2': { users: true }, '3': 'GENERAL' }
[34mI20171014-12:51:53.366(0) [34mMeteor ➔ method stream-notify-room -> userId: pW7K8cN57FkwNz648 , arguments: { '0': 'GENERAL/typing', '1': 'Nietzsche', '2': false }
[34mI20171014-12:51:53.373(0) [34mMeteor ➔ method sendMessage -> userId: pW7K8cN57FkwNz648 , arguments: { '0': { _id: 'EEciuMLgsHJbp4kLF', rid: 'GENERAL', msg: '@Alhrath ' } }
[34mI20171014-12:51:53.375(0) [34mMeteor ➔ method canAccessRoom -> userId: pW7K8cN57FkwNz648 , arguments: { '0': 'GENERAL', '1': 'pW7K8cN57FkwNz648' }
[34mI20171014-12:51:53.414(0) [34mIntegrations ➔ Outgoing WebHook.debug Execute Trigger: sendMessage
[34mI20171014-12:51:53.416(0) [34mIntegrations ➔ 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' ] } }
[34mI20171014-12:51:53.417(0) [34mIntegrations ➔ Outgoing WebHook.debug Starting search for triggers for the room: GENERAL
[34mI20171014-12:51:53.417(0) [34mIntegrations ➔ Outgoing WebHook.debug Found 0 to iterate over and see if the match the event.
[34mI20171014-12:51:54.039(0) Push: send message "#general" via query { userId: '4HMTei6gZLPch3TRp' }
[34mI20171014-12:51:54.042(0) Push: send to token { gcm: 'dyZQbw8T1Qg:APA91bGLyhC18GXCArzatJmLP5Xx-W5gNAatKorNMnzQi6bchEODnot3DmrKU5CkAWIXf0md-3GnVlrZYcr5hhh8U9g0rHY1_RQGcNnmh6dmxv-vq1xNbJe-iLdkP7Gg8PEKK-zrfQmb' }
[34mI20171014-12:51:55.922(0) [34mMeteor ➔ method spotlight -> userId: mgpsxDZJQtnuFEQHr , arguments: { '0': 'alh', '1': [ 'Alhrath' ], '2': { users: true }, '3': 'GENERAL' }
[34mI20171014-12:52:02.040(0) [34mMeteor ➔ method readMessages -> userId: mgpsxDZJQtnuFEQHr , arguments: { '0': 'GENERAL' }
Log when desktop app is connected with away status (push notification not sent) :
[34mI20171014-12:56:31.223(0) [34mMeteor ➔ method stream-notify-room -> userId: pW7K8cN57FkwNz648 , arguments: { '0': 'GENERAL/typing', '1': 'Nietzsche', '2': true }
[34mI20171014-12:56:32.203(0) [34mMeteor ➔ method spotlight -> userId: pW7K8cN57FkwNz648 , arguments: { '0': 'alh', '1': [ 'Alhrath' ], '2': { users: true }, '3': 'GENERAL' }
[34mI20171014-12:56:34.012(0) [34mMeteor ➔ method stream-notify-room -> userId: pW7K8cN57FkwNz648 , arguments: { '0': 'GENERAL/typing', '1': 'Nietzsche', '2': false }
[34mI20171014-12:56:34.016(0) [34mMeteor ➔ method sendMessage -> userId: pW7K8cN57FkwNz648 , arguments: { '0': { _id: 'N6EgHYJYknPmNFdmk', rid: 'GENERAL', msg: '@Alhrath ' } }
[34mI20171014-12:56:34.018(0) [34mMeteor ➔ method canAccessRoom -> userId: pW7K8cN57FkwNz648 , arguments: { '0': 'GENERAL', '1': 'pW7K8cN57FkwNz648' }
[34mI20171014-12:56:34.043(0) [34mIntegrations ➔ Outgoing WebHook.debug Execute Trigger: sendMessage
[34mI20171014-12:56:34.045(0) [34mIntegrations ➔ 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' ] } }
[34mI20171014-12:56:34.047(0) [34mIntegrations ➔ Outgoing WebHook.debug Starting search for triggers for the room: GENERAL
[34mI20171014-12:56:34.047(0) [34mIntegrations ➔ Outgoing WebHook.debug Found 0 to iterate over and see if the match the event.
[34mI20171014-12:56:34.276(0) [34mMeteor ➔ method spotlight -> userId: mgpsxDZJQtnuFEQHr , arguments: { '0': 'alh', '1': [ 'Alhrath' ], '2': { users: true }, '3': 'GENERAL' }
[34mI20171014-12:56:37.763(0) [34mMeteor ➔ method readMessages -> userId: mgpsxDZJQtnuFEQHr , arguments: { '0': 'GENERAL' }
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
have same issue (version 0.59.1)
@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 ...
cannot choose push to both device ? pc and mobile app ?
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: {
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.
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?
have same issue (version 0.59.3) as @Alhrath
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 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:
