实施推送通知的推荐方式

发布于 2024-12-15 18:00:39 字数 748 浏览 7 评论 0原文

我正在为 Android 和 iPhone 构建一个应用程序。此应用程序需要接收用户收件箱中新消息的通知。作为应用程序开发中的菜鸟,我想知道你们中是否有人可以建议实现我在这里需要的内容的最佳方法。

我对 Android 的了解比对 iPhone 的了解更多,所以我对 iPhone 的理解可能还不够。根据我所阅读和理解的内容,我相信我需要在我的应用程序第一次启动时启动一项服务(或者指示设备在每次设备启动时启动服务或其他)。然后,该服务将与服务器交互以接收通知并显示它们。单击通知将启动该应用程序。

我的选项是

  1. C2DM 或 APNS

  2. Urban Airship

  3. 我自己的服务器主要使用与客户端的空闲 TCP 连接。

根据我选择的选项,我的客户端实现以及服务器端实现都会发生变化。

你们会推荐什么?还有其他方法可以完成我需要做的事情吗?

非常感谢任何帮助。

更新:

基于 jbat100 答案。事实上,Apple 不允许我编写自己的服务器来直接与我的应用程序通信以获取通知,这意味着必须使用 APNS。所以选项 3 就完全退出了。这意味着我们要么使用 Urban Airship,要么直接与 APNS 和 C2DM 连接。根据我的研究,这两种情况所涉及的工作量是相当的,因此仅仅为了支持通知而额外花费 4-5K/月 是没有意义的。所以我打算实施方案1。如果有人不这么认为,请在下面留言。

谢谢。

I am building an App for Android and iPhone. This app needs to receive notification for new messages in user's inbox. Being a total noob in app dev, I was wondering if any of you guys could suggest the best way to implement what I need here.

I have read up more on Android than iPhone so my understanding of latter may be wanting. Based on what I have read and understood, I believe that I will need to start a service when my app launches for the first time (or instruct the device to start the service every time the device starts or something). This service will then interface with a server to receive notifications and display them. Clicking on the notification will launch the app.

My options are

  1. C2DM or APNS

  2. Urban Airship

  3. My own server using mostly idle TCP connection with client.

Depending upon the option I choose, my client side implementation as well as server side implementation changes.

What will you guys recommend? Is there any other way to do what I need done?

Any help is greatly appreciated.

Update:

Building on jbat100 answer. The fact that Apple does not allow me to write my own server to communicate directly with my app for notifications means that APNS must be used. So option 3 is out altogether. This means we are left with either Urban Airship or interfacing directly with APNS and C2DM. Based on my research, the effort involved in both cases is comparable so it does not make sense to shell out 4-5K /mo extra just to support notification. So I plan to implement option 1. If any of you think otherwise, please leave comments below.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

习惯成性 2024-12-22 18:00:39

它们必须单独处理。对于 iOS 推送通知,您必须阅读 Apple 推送通知服务(编程指南 此处),它们有一个非常具体的协议,您的服务器必须遵守提供商与 Apple 推送通知服务的通信。不知道 Android 怎么样,它可能会有很大不同,不太集中。

They will have to be handled separately. In the case of iOS push notifications, you will have to go through the Apple Push Notification Service (Programming Guide here), they have a very specific protocol your server will have to conform to which is described in the Provider Communication with Apple Push Notification Service. Don't know about Android, it will probably be quite different, less centralized.

屌丝范 2024-12-22 18:00:39

基于 jbat100 答案。事实上,Apple 不允许我编写自己的服务器来直接与我的应用程序通信以获取通知,这意味着必须使用 APNS。所以选项 3 就完全退出了。这意味着我们要么使用 Urban Airship,要么直接与 APNS 和 C2DM 连接。根据我的研究,这两种情况所涉及的工作量是相当的,因此仅仅为了支持通知而额外花费 4-5K/月 是没有意义的。所以我打算实施方案1。如果有人不这么认为,请在下面留言。

Building on jbat100 answer. The fact that Apple does not allow me to write my own server to communicate directly with my app for notifications means that APNS must be used. So option 3 is out altogether. This means we are left with either Urban Airship or interfacing directly with APNS and C2DM. Based on my research, the effort involved in both cases is comparable so it does not make sense to shell out 4-5K /mo extra just to support notification. So I plan to implement option 1. If any of you think otherwise, please leave comments below.

只为一人 2024-12-22 18:00:39

C2DM 也许是最简单的。但是,我想你也可以尝试一下Urban Ship。实现自己的服务器是一件痛苦的事情。

C2DM would be the easiest perhaps. But, I think you can also try Urban Ship. Implementing your own server is a pain.

原来分手还会想你 2024-12-22 18:00:39

我的情况非常相似,我首先发布了 Android 应用程序,现在正在开发 iOS 应用程序。对于 Android,我使用 C2DM 实现了推送通知,并从我的 Google App Engine (GAE) 应用程序发送通知。 C2DM 基本上需要将 HTTP 消息发送到 Google 的服务器。因此,您将 HTTP POST 发送到 URL https://android.apis.google.com/c2dm /发送

然而,iOS 需要在专有端口上建立专用 TCP 连接,并且 GAE 环境不允许除端口 80 上的 HTTP 之外的任何外部协议。因此,我进行了大量研究,Urban Airship 似乎是答案。他们提供了一个 HTTP 接口,我可以从我的 GAE 环境访问该接口,并将其转换为 Apple 服务器可以理解的协议。不过,他们的定价似乎令人困惑——每月 100 万条免费通知,之后每条通知收取十分之一美分。这很奇怪,因为他们每月免费赠送 1000 美元?经济上非常奇怪。我正在考虑尝试它们,但我认为最好的大批量替代方案是仅使用您自己的实现,并将其部署在亚马逊的 AWS 上或购买其他廉价的第三方托管。

My situation is very similar, and I released my Android app first, and am now working on an iOS app. For Android, I implemented push notifications using C2DM, and I send the notifications from my Google App Engine (GAE) app. C2DM basically requires sending HTTP messages to Google's server. So, you send an HTTP POST to the URL https://android.apis.google.com/c2dm/send.

iOS however, requires a dedicated TCP connection on a proprietary port, and GAE environment doesn't allow any external protocol except HTTP over port 80. So, I have researched a lot and Urban Airship seems to be the answer. They provide an HTTP interface, which I can access from my GAE environment, and they convert that to the protocol that Apple's servers understand. Their pricing seems confusing though - 1 million free notifications per month, and a tenth of a cent per notification after that. That's bizzare because they're giving away $1000 free a month? Very economically weird. I'm considering trying them out, but I think the best high-volume alternative is to just use your own implementation, and deploy it on Amazon's AWS or buy other cheap 3rd party hosting.

似最初 2024-12-22 18:00:39

重要提示:自 2012 年 6 月 26 日起,C2DM 已正式弃用。这意味着 C2DM 已停止接受新用户和配额请求。 C2DM 不会添加新功能。但是,使用 C2DM 的应用程序将继续运行。我们鼓励现有 C2DM 开发人员迁移到新版本的 C2DM,即 Google Cloud Messaging for Android (GCM)。有关更多信息,请参阅 C2DM 到 GCM 迁移文档。开发者必须使用GCM进行新的开发。

Important: C2DM has been officially deprecated as of June 26, 2012. This means that C2DM has stopped accepting new users and quota requests. No new features will be added to C2DM. However, apps using C2DM will continue to work. Existing C2DM developers are encouraged to migrate to the new version of C2DM, called Google Cloud Messaging for Android (GCM). See the C2DM-to-GCM Migration document for more information. Developers must use GCM for new development.

浪菊怪哟 2024-12-22 18:00:39

我无法透露 Android 方面的情况,但我可以告诉您,我最近在 Heroku 上设置了一个极其简单的 Rails 应用程序,它通过 APNS 向我的 iOS 应用程序发送推送通知。我使用了 houston gem,并且从我开始使用后不到 20 分钟就在我的 iOS 应用程序中收到了推送通知的努力。

I can't shed any light on the Android side of the equation, but I can tell you that I recently setup an incredibly simple Rails app on Heroku that sends push notifications to my iOS app via APNS. I used the houston gem and was receiving push notifications in my iOS app in less than 20 minutes from when I started the effort.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文