[英]how to send a push notification from an android app running on a device to another device running the same app?
I am new to android and am making a simple app for my college project. 我是Android新手,正在为我的大学项目制作一个简单的应用程序。 The app runs on a simple concept wherein a faculty can know his/her examination duties(which room number is allocated to her for invigilating)and can thus register and login on the app. 该应用程序以一个简单的概念运行,在该概念中,教师可以知道他/她的检查职责(分配给她的房间号以进行授课),因此可以在该应用程序上注册和登录。 After logging in, he/she will receive a room number. 登录后,他/她将收到一个房间号。 He/she can get a list of all other faculties with their respective duties. 他/她可以获取所有其他学院及其职责的清单。
Now I want to add another service which will allow a faculty to send a notification to another faculty using the app for swapping room duties. 现在,我想添加另一项服务,该服务将允许教师使用该应用程序向另一位教师发送通知以交换房间职责。 When sent, another faculty receives a push notification over the net on their app. 发送后,另一位教师会在其应用程序上通过网络接收推送通知。
I am reading about google gcm but cannot find a solution. 我正在阅读有关google gcm的信息,但找不到解决方案。
Thanks in advance. 提前致谢。
First, you must register your app on GCM, GCM will give you a regID
with one device. 首先,您必须在GCM上注册您的应用,GCM会通过一个设备为您提供regID
。 And you must have a server side, the server side stores all regIDs. 并且您必须具有服务器端,该服务器端存储所有regID。 When you need to push a notification for the other devices, you send a request to your server side, the server side will send a request to GCM with the regIDs (depend on you) then GCM will push notification to all devices. 当您需要向其他设备推送通知时,您会向服务器端发送请求,服务器端会使用regID(取决于您)向GCM发送请求,然后GCM会将通知推送至所有设备。 The workflow: 工作流程:
1. Your phone app will register on GCM, take a regID. 1.您的电话应用将在GCM上注册,并使用regID。 Your server side saves this regID. 您的服务器端将保存此regID。
2. You will send a request to your server side. 2.您将向服务器端发送请求。 The server side will use this request to make another request include all or some regIDs, and send this request to GCM. 服务器端将使用此请求使另一个请求包含所有或某些regID,并将此请求发送到GCM。
3. GCM will take regIDs from the request, and push notification to the device which have regID match with one of regID in the request. 3. GCM将从请求中获取regID,并将通知与请求中的regID之一匹配的设备推送到设备。
For more details, please read this: https://developers.google.com/cloud-messaging/gcm 有关更多详细信息,请阅读以下内容: https : //developers.google.com/cloud-messaging/gcm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.