Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[User Still Receive Push Notification When Online] #57

Closed
riandyrn opened this issue Dec 24, 2017 · 4 comments
Closed

[User Still Receive Push Notification When Online] #57

riandyrn opened this issue Dec 24, 2017 · 4 comments

Comments

@riandyrn
Copy link
Contributor

Hello, Gene

I found that in current push implementation, if a user doesn’t subscribe to topic, even though he is online, he will still receive push notification when there is new message on the topic.

You could see the details here, which shown topic only exclude device ids which subscribed to current topic.

I think this behavior will annoys user though. Because even though user is already online in app he would still receive notification.

What do you think?

Thanks

@or-else
Copy link
Contributor

or-else commented Dec 24, 2017

Hi Riandy,

I think the comment in the code is incorrect but the code itself is correct. The code you pointed out collects device IDs which later are excluded. Take a look here https://github.com/tinode/chat/blob/devel/push_fcm/push_fcm.go#L73-L80
It skips the device IDs which were online and received the message. It sends to devices which were NOT online: https://github.com/tinode/chat/blob/master/push_fcm/push_fcm.go#L91

@riandyrn
Copy link
Contributor Author

The code you pointed out collects device IDs which later are excluded.

Yes, I’m aware of that. Hehe…

If we take a look at this block, we will see that the topic only exclude device ids which session is attached to that topic.

So for example, if user A is online by subscribing to “me” topic but he doesn’t subscribe to “topic_A”, then when there is new message in “topic_A”, user A will still receive push notification.

So in the end, user A would receive both {pres} & push notification.

This is the problem which I’m trying to address.

@or-else
Copy link
Contributor

or-else commented Dec 24, 2017

So for example, if user A is online by subscribing to “me” topic but he doesn’t subscribe to “topic_A”, then when there is new message in “topic_A”, user A will still receive push notification.

Correct, the user will receive both {pres} and push. But I think that's the desired behavior. Is it not? I just checked Telegram and WhatsApp and both of them behaved in this exact way. It seems logical. What am I missing?

@riandyrn
Copy link
Contributor Author

Lol..🤣

Yeah, you’re right, Gene. I just checked it too. Whatsapp also have the same behavior.

I was under impression that push message should only be used when socket connection is not established between client & server. So I thought when user online, the server should not send push message towards the client.

But after observing Whatsapp, it is much better with this behavior. Because user become more aware that there is new message incoming 👍 .

Thanks a lot, Gene. Sorry to bother you. Lol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants