简体   繁体   English

用iPhone推送通知

[英]push notifications with iPhone

Let's say that i am building an app for a 5 location restaurant. 假设我正在为5位餐厅构建应用程序。 The user would choose which restaurant that they will allow "push notifications" from. 用户将选择他们将允许“推送通知”的餐厅。 Is this possible? 这可能吗? Is it possible to allow a specific segment of an app to send notifications to a specific segment of users? 是否可以允许应用的特定片段向特定的用户群发送通知?

thanks 谢谢

The answer is yes, it is possible to send notifications to a subset of your users, both in iOS and android applications. 答案是肯定的,可以在iOS和Android应用程序中向用户的子集发送通知。

For both iOS and android, requests for push notifications are sent to Apple or Google servers requesting messages be sent to specific users. 对于iOS和Android,推送通知请求将发送到Apple或Google服务器,请求将消息发送给特定用户。 The application requesting these push notifications (which we call a 'push server' at my company) can, therefore, selectively send push notifications. 因此,请求这些推送通知的应用程序(我们称之为我公司的“推送服务器”)可以选择性地发送推送通知。

The only requirement, then, is that your push server be able to dynamically determine which users should receive a given notification. 因此,唯一的要求是您的推送服务器能够动态确定哪些用户应该收到给定的通知。 You would have to do the following: 您必须执行以下操作:

  • When a user selects their restaurant preferences, make a (presumably asynchronous) call to your back-end, where these preferences will be stored (in a database table, for example). 当用户选择他们的餐馆偏好时,对您的后端进行(可能是异步的)呼叫,这些偏好将被存储(例如,在数据库表中)。
  • When you are ready to send a push notification, query this data source to determine what subset of your users have elected to receive notifications from the appropriate restaurant 当您准备好发送推送通知时,请查询此数据源以确定您的用户的哪个子集已选择接收来自相应餐厅的通知
  • Loop through the list of users who are to receive a notification, retrieve the relevant push token for each user, and initiate the push request by sending a message to the appropriate server (ie Google / Apple) 遍历要接收通知的用户列表,检索每个用户的相关推送令牌,并通过向相应的服务器(即Google / Apple)发送消息来发起推送请求

Hope this helps! 希望这可以帮助!

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

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