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

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

问题描述

我正在研究一种需要支持允许多个用户使用的应用程序的推送架构.这意味着多个用户可以使用他们的凭据登录应用程序.我遇到的问题是,如果用户 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天全站免登陆