简体   繁体   English

iOS推送通知 - 向所有人发送消息

[英]iOS push notification - send a message to everyone

I'm writing my first iOS app with push notification and so far so good. 我正在用推送通知编写我的第一个iOS应用程序,到目前为止一直很好。 I'm able to send notifications from a web server as long as I enter the device token of the receiver. 只要我输入接收器的设备令牌,我就能从Web服务器发送通知。

So I was wondering: Is there a simple way to send a notification to everyone who has the app installed? 所以我想知道:是否有一种简单的方法可以向安装了该应用的所有人发送通知? Or do I have to make the manually register with the push server when it launches? 或者我必须在推送服务器时手动注册推送服务器?

Is there any guidelines on how this is done? 有关如何做到这一点的指导方针吗?

You do not need to enter any devices manually on the server and shall not. 您无需在服务器上手动输入任何设备,也不需要。 It is the application which has the responsibility to register its token on your server. 应用程序有责任在您的服务器上注册其令牌。

The server must keep a list of all tokens of all the registered devices. 服务器必须保留所有已注册设备的所有令牌的列表。 Whenever you want to push a message to all the devices, loop through your list of device tokens. 每当您想要将消息推送到所有设备时,请遍历您的设备令牌列表。

If the user does not want to receive any push notifications, the user can cancel push notifications in the settings. 如果用户不想接收任何推送通知,则用户可以在设置中取消推送通知。

Please read the official documentation about Push Notifications . 请阅读有关推送通知的官方文档。

You have to save all the Data on your server. 您必须保存服务器上的所有数据。 Then you can loop through all your data and voila you can send a message to everyone. 然后,您可以遍历所有数据,然后您可以向所有人发送消息。

And yes you have to register all manually to the push server. 是的,你必须手动注册到推送服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM