[英]How can a messaging server indetify target client and send push notification
My clients are Android devices. 我的客户是Android设备。 A client wants to send some info to another client which will first be sent to the app server and then the server will notify a middleware service(some kind of message broker) which will be responsible for sending the target client a push notification(to tell it to poll from the app server). 客户端要向其他客户端发送一些信息,该信息首先将发送到应用服务器,然后服务器将通知中间件服务(某种消息代理),该中间件服务将负责向目标客户端发送推送通知(以告知从应用服务器轮询)。
I want to know: 我想知道:
How will this middleware service identify which client device to notify? 该中间件服务将如何识别要通知的客户端设备?
more concretely, How does a push notification server locate which physical device to fire off the notification to? 更具体地讲, 推送通知服务器如何定位向哪个物理设备触发通知?
My requirement is that the client should be able to obtain notifications even while using a VPN or proxy(similar to WhatsApp). 我的要求是,即使使用VPN或代理(类似于WhatsApp),客户端也应该能够获取通知。 Also, if the client is powered off then the middleware queues the messages and delivers them once the client power backs on again. 同样,如果客户端断电,则中间件将消息排队,并在客户端电源再次打开后将其传递。
I have been looking at things like Firebase Cloud Messaging and MQTT brokers and stuff but I want to implement similar things on my own. 我一直在研究诸如Firebase Cloud Messaging和MQTT代理之类的东西,但是我想自己实现类似的东西。
I want to implement this in Java. 我想用Java实现。
Your client ( having an unique id and token ) will send the message to another client who also have a unique id and token in the database .. So the, 您的客户端( 具有唯一的ID和令牌 )会将消息发送给另一个客户端,该客户端在数据库中也具有唯一的ID和令牌 。因此,
Server will map the receivers' id to the receivers token and send the notification to the receiver.. 服务器会将接收者的ID映射到接收者令牌,并将通知发送给接收者。
The database(backend) will have unique ids (maybe primary keys) against each client and also a unique token (for sending notification) against each client. 数据库(后端)将具有针对每个客户端的唯一ID(可能是主键),并且还将具有针对每个客户端的唯一令牌(用于发送通知)。 So , when the sender-client sends the message , the backend script maps the receiver-client's (to whom the sender is sending) id
to the receiver clients token. 因此,当发送方-客户端发送消息时,后端脚本会将接收方-客户端(发送方正在向其发送)的id
映射到接收方客户端令牌。 Then send the notification to the particular token. 然后将通知发送到特定令牌。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.