推送通知技术如何在 Android 上工作? [英] How does push notification technology work on Android?

查看:24
本文介绍了推送通知技术如何在 Android 上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google 如何实现其推送通知功能?它是通过在后台运行的服务完成的轮询还是以其他方式工作?

How has Google implemented their push notification feature? Does it work through polling done by a service running in the background or in a different way?

推荐答案

从我在以色列 Android 开发者大会上听到的:

From what I've heard during an Android developers conference in Israel:

接受模式 在谷歌云服务器上.TCP 连接已由 Google Play 应用程序启动.这就是为什么必须在设备上安装 Google Play 才能制作 Google Cloud Messaging (GCM)(以前称为Android 云到设备消息传递服务 - C2DM) 工作.

There is simply a TCP socket waiting in accept mode on a cloud Google server. The TCP connection had been initiated by the Google Play application. That's why Google Play must be installed on the device for making Google Cloud Messaging (GCM) (formerly Android Cloud to Device Messaging Service - C2DM) work.

当这个 TCP 客户端套接字接收到一些消息时,该消息包含诸如它应该被寻址到的应用程序的包名称之类的信息,当然 - 数据本身.这些数据被解析并打包成一个 intent 被广播并最终接收由应用程序.

When this TCP client socket receives some message, the message contains information such as the package name of the application it should be addressed to, and of course - the data itself. This data is parsed and packed into an intent that is broadcast and eventually received by the application.

即使设备的无线电状态变为空闲"模式,TCP 套接字也保持打开状态.应用程序不必运行即可接收意图.

The TCP socket stays open even when the device's radio state turns into "idle" mode. Applications don't have to be running to receive the intents.

更多信息请访问 http://developer.android.com/google/gcm/gcm.html

这篇关于推送通知技术如何在 Android 上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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