一台服务器发送推送通知到Android和iOS设备 [英] One server sending push notifications to Android and iOS devices

查看:227
本文介绍了一台服务器发送推送通知到Android和iOS设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的组织有和Android应用程序和iOS应用程序。我们要开始推通知这些应用程序。

Our organization has and android app and an iOS app. We want to start pushing notification to these apps.

Android有GCM。 苹果公司APNS。

Android has GCM. Apple has APNS.

什么是最简单的方法来设置一个服务器,以便推送通知需要发送的时候,它确切地知道将消息发送到哪个服务器?

What is the easiest way to setup a server so that when a push notification needs to be sent, it knows exactly which server to send the message to?

推荐答案

作为一个小的背景,这是一所大学的环境,多个学院的应用程序,以及远程教育可能正在使用该服务。下面是我们在我们的组织所使用的方法。如果你看一下的方式APNS的工作就可以由只发送一个网页调用APNS服务的标记ID。 GCM是非常接近的同类型的系统。基本上创建一个JSON包并将其发送到所希望的服务。

As a little background this is for a university setting where multiple colleges apps as well as distance education may be using the service. Here is the approach that we are using in our organization. If you look at the way APNS works it can be used by just sending a web call to the APNS service with the token id. GCM is very close to the same type of system. Basically create a JSON package and send it to the desired service.

下面是我们的脚步,我们用于创建此服务。

Here is our steps we used to create this service.

  1. 服务器管理员创建的服务器和数据库,可以被称为是将收集来自An​​droid和iOS设备的标记。当设备注册,我们也把它是什么类型的设备。这是可能的,因为我们只是将数据发送到一个已创建的数据库。

  1. Server admins created a server and database that can be called that will collect the tokens from both android and ios devices. When the device registers we also send what type of device it is. This is possible since we are just sending data to the database that is has been created.

从这里我们再创建一对夫妇的发送数据做所需要的服务,无论是IOS还是Android的Python脚本。这些脚本收集来自数据库中的相应数据并将打包的数据(JSON包),以APNS为iOS邮件和GCM对谷歌的云。

From here we then created a couple of python scripts that send the data do the desired service whether it is ios or android. These scripts gather the appropriate data from the database and sends the packaged data (JSON package) to APNS for ios message and GCM for google cloud.

我们还创建了一个Web界面,使那些谁需要发送邮件到CAN设备。

We also created a web interface so that those who need to send messages to the devices can.

实施的其余部分是由你来决定使用该服务的最佳途径。例如,当检查无效的设备, 因为我们计划使用同一台服务器用于多个应用,我们可以发送设备,令牌,应用程序,或任何其他的应用程序需要从别人那里我们生产区分开来的类型,这样每一个想要使用可以在服务应用程序。我希望这可以帮助,让您对如何实现这一目标有了一些了解。

The rest of the implementation is up to you to decide the best way to utilize the service. For example when to check for invalid devices, Because we are planning on using this same server for multiple applications we can send the type of device, token, application, or whatever else is needed for an application to distinguish it from others we produce so that each application that wants to use the service can. I hope this helps and gives you some idea on how to accomplish this.

这篇关于一台服务器发送推送通知到Android和iOS设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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