Google Cloud Messaging的目的是什么 [英] What is the purpose of Google Cloud Messaging

查看:121
本文介绍了Google Cloud Messaging的目的是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读有关Google Cloud Messaging的信息,作为一名开发人员,我的问题是这是做什么用的?"谁能提供一个示例将其用于什么?我不是在寻找源代码.相反,我对人们对其使用的想法感到好奇.

I have been reading about google Cloud Messaging and as a developer my question is " What is this for?" Can anyone provide an example of what one would use this for? Im not looking for source code. Instead I am curious about the ideas people have for its use.

推荐答案

来自 Google文档:

适用于Android的Google Cloud Messaging(GCM)是一项服务,可帮助开发人员将服务器中的数据发送到Android设备上的Android应用程序.这可能是一条轻量级消息,告诉Android应用程序有新数据要从服务器中获取(例如,朋友上传的电影),也可能是一条消息,其中包含多达4kb的有效载荷数据(因此类似即时消息传递可以直接使用该消息). GCM服务处理消息排队以及将消息传送到目标设备上运行的目标Android应用程序的所有方面

Google Cloud Messaging for Android (GCM) is a service that helps developers send data from servers to their Android applications on Android devices. This could be a lightweight message telling the Android application that there is new data to be fetched from the server (for instance, a movie uploaded by a friend), or it could be a message containing up to 4kb of payload data (so apps like instant messaging can consume the message directly). The GCM service handles all aspects of queueing of messages and delivery to the target Android application running on the target device

真的很自我解释.这只是一种将小消息从外部/网络服务发送到手机以使应用程序起作用的机制.这要比依靠完全手工编码的协议依靠JSON或XML来实现一个完整的自定义程序包要容易得多. (并不是说经常使用现成的"工具提供了一个非常优雅的解决方案!)

Pretty self explanatory really. It's just a mechanism for sending small messages from an external/network service to a handset for the app to act upon. It's a lot more easier than implementing a complete custom package relying on the likes of JSON or XML with a completely hand-coded protocol. (Not to say that often using tools 'off the shelf' presents a pretty elegant solution!)

过去,我实现了一个简单的视频播客风格的应用程序;没什么好奇怪的-只是等待服务器上的新内容.在这种情况下,我必须专门编写代码,以便该应用在启动时查询服务器,然后下载视频文件.显然,替代方案是该应用程序每隔 x 分钟或小时对服务器进行一次查询.

In the past I was implementing a simple video podcast style app; nothing amazing - just waiting on new content from the server. In this scenario I had to specifically code things up so that the app queried the server upon launch, and then downloaded the video files. The alternative obviously being that the app queried the server every x minutes or hours.

现在,借助GCM,我可以重新编写该应用程序,并让服务器通知该应用程序,而无需该应用程序启动操作.自然,在移动设备上,这比使应用程序连接到服务器并无缘无故地多次查询更为可取;并且最好还是启动一个应用程序,并且必须等待它从服务器请求更新.

Now with GCM I could re-write that app and have the server inform the app without the requirement for the app to initiate the action. Naturally, on a mobile this is preferable to having the app connect to the server and query it multiple times for no real reason; and it's also preferable to launching an app and having to wait whilst it requests updates from server.

上段中的示例是显而易见的应用-但有些想像力,它的使用范围还可以更多.

The examples in the above paragraph are the obvious applications - but with some imagination it can be used for a lot more.

我想要记住的主要事情是找到用于该目的的工具,而不是该工具的目的!如果需要,它就在其中-但不要尝试将其楔入不需要的地方!

I think the main thing to remember though is Find a tool for the purpose, not a purpose for the tool! If you need it, it's there - but don't try and wedge it in where it's not required!

这篇关于Google Cloud Messaging的目的是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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