在多用户应用程序中推送通知的最佳做法? [英] Best practices for push notifications in multi user applications?

查看:148
本文介绍了在多用户应用程序中推送通知的最佳做法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一种推式架构,该架构需要支持允许多个用户使用的应用程序.这意味着一个以上的用户可以使用其凭据登录到该应用程序.我遇到的问题是,如果用户A允许推送通知,然后注销,然后用户B登录并开始获取用户A的推送通知,那么该怎么办?

I'm working on a push architecture that needs to support applications which allow for multiple users. This means more than one user can log into the application with their credentials. The problem I'm running into is what if user A allows push notifications, then logs out, then user B logs in and starts getting user A's push notifications?

处理此类事情的最佳做法是什么?我曾经想过的一个想法是,您可能记得最后一个登录的用户,并且只向已登录"用户显示推送通知.您将必须在消息有效负载中发送某种用户上下文,以便可以根据已登录的用户对其进行检查.但是,这有点时髦.

What are some best practices for handling this type of thing? One thought I had was you could remember the last user who logged in and only display push notifications to the "logged in" user. You would have to send some sort of user context in the message payload so it could be checked against the logged in user. However this feels a little funky.

还有其他人碰到这个吗?这似乎是一个非常相关的问题,尤其是对于那些家庭倾向于共享设备的平板电脑而言.

Anyone else ran into this? It's seems like a really relevant problem, especially for tablets where families tend to share the device.

推荐答案

我认为您的建议在多用户应用中可以接受.与在服务器端相比,在客户端实现这一点要简单得多.缺点是浪费了多余的带宽来发送不必要的通知.但是,绝大多数用法可能是单用户,因此这可能没什么大碍.

I think your suggestion is acceptable in a multi-user app. It is much simpler to implement this in the client side, than on the server side. The downside is extra bandwidth wasted to send an unneeded notification. But vast majority of the usage is probably single-user so this may not matter much.

另一种方法是跟踪服务器上已登录的用户及其当前reg_id.这可能更加复杂,因为A可以在多个设备上登录,然后从设备1注销,而B登录到设备1,依此类推,并且服务器必须跟踪所有这些.因此,可能会有另一个表来跟踪已登录用户"与注册ID"之间的关系.

The alternative is to track the logged on users on your server and their current reg_ids. This could be more complicated because A could be logged on on multiple devices, then logs out from device 1, and B logs onto device 1, etc. and your server has to track all of these. So probably another table to track the relationships between 'Logged On Users' to 'Reg Ids'.

如果您讨厌发送不需要的通知的想法,请选择服务器路由.如果您重视Keep-It-Simple原则,请遵循客户端路由.

If you hate the idea of sending unneeded notifications, go with the server route. If you value Keep-It-Simple principle, go with the client route.

这篇关于在多用户应用程序中推送通知的最佳做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆