简体   繁体   English

Google Cloud Messaging for Android库与Google Play服务

[英]Google Cloud Messaging for Android library vs. Google Play Services

Current Google GCM documentation requires you to install Google Play Services and to use them for GCM (Google Cloud Messaging). 目前的Google GCM文档要求您安装Google Play服务并将其用于GCM(Google Cloud Messaging)。 The library is 1.1MB, yet my current .apk is half that size. 该库是1.1MB,但我目前的.apk是这个大小的一半。 My app is intended to receive GCM and display some data on the screen, so I don't need Google Play Services' Maps API, G+ login, etc. Nor I need to be able to respond back to the server after getting GCM. 我的应用程序旨在接收GCM并在屏幕上显示一些数据,因此我不需要Google Play服务的Maps API,G +登录等。我也不需要在获得GCM后能够回复服务器。

SDK Manager allows download and installation of standalone Google Cloud Messaging for Android package. SDK Manager允许下载和安装独立的Google Cloud Messaging for Android软件包。 It is the one that was used before Google I/O 2013, where Play Services were announced. 这是在Google I / O 2013之前使用的,Play服务宣布的地方。

My question is: what is the difference in performance between GPS's GCM and standalone GCM for Android? 我的问题是:GPS的GCM和Android的独立GCM之间的性能差异是什么? Do I really have to switch to GPS? 我真的必须切换到GPS吗? Is standalone GCM depricated? 独立GCM是否已被删除? Can I still receive data (up to 4K) with standalone GCM? 我还可以使用独立GCM接收数据(最高4K)吗?

As far as I know, yes, the old one is deprecated (it says so here http://developer.android.com/reference/gcm-packages.html ), but still works. 据我所知,是的,旧版本已被弃用(在http://developer.android.com/reference/gcm-packages.html中也是如此),但仍然有效。

I would recommend using the Play Services version, though, since it's MUCH easier to configure and use, and if you don't need G+ login or anything else you don't have to use it. 我建议使用播放服务版本,因为它更容易配置和使用,如果你不需要G +登录或其他任何你不必使用它。 Yes, your APK will be a little bit bigger, but I think it's worth it. 是的,你的APK会更大一些,但我认为这是值得的。

Plus, any new features or improvements to the protocol will most likely be only for the Play Services library, and not for the old one. 此外,协议的任何新功能或改进很可能仅适用于Play服务库,而不适用于旧服务库。

The old GCM though deprecated, still works. 旧的GCM虽然已弃用,但仍然有效。 And there is a probability it will be working for some more time. 而且它有可能会再工作一段时间。 Personally, I implemented the new GCM using the play services and it seems to be buggy as there were devices that could not get the registration ID and got the SERVICE_NOT_AVAILABLE error. 就个人而言,我使用播放服务实现了新的GCM,并且它似乎有些错误,因为有些设备无法获取注册ID并且收到了SERVICE_NOT_AVAILABLE错误。 So after some research I wasn't able to find a solution for it, and reverted to the old GCM method that uses GCMIntentService, and I was able to get back the registration IDs. 因此经过一些研究后,我无法找到它的解决方案,并恢复到使用GCMIntentService的旧GCM方法,我能够取回注册ID。 Bottom Line : Seems you can use the old GCM method for the time being. 底线:似乎您可以暂时使用旧的GCM方法。

You don't need to worry much about increase in app size while using GCM using Play Services as long as you're using Proguard. 只要您使用Proguard,在使用Play服务使用GCM时,您无需担心增加应用程序大小。

Description of The Google Play services client library mentions Google Play服务客户端库的说明提及

The client library has a light footprint if you use ProGuard as part of your build process, so it won't have an adverse impact on your app's file size. 如果您在构建过程中使用ProGuard ,则客户端库占用空间小,因此不会对应用程序的文件大小产生负面影响。

I haven't myself measured the difference in apk with the two different approaches. 我没有自己测量apk与两种不同方法的区别。 Will update if I do. 如果我这样做会更新。

新的GCM方法也使用GcmIntentService来保持接收消息的句柄配置以及我配置sendNotification(msg)方法的位置

Check the device to make sure it has the Google Play Services APK. 检查设备以确保其具有Google Play服务APK。 If it doesn't, display a dialog that allows users to download the APK from the Google Play Store or enable it in the device's system settings. 如果没有,则显示一个对话框,允许用户从Google Play商店下载APK或在设备的系统设置中启用它。

It will save you from project memory size. 它将节省您的项目内存大小。

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

相关问题 Google Cloud Messaging与Android Services - Google Cloud Messaging vs Android Services 无法为Google云消息传递配置Google Play服务 - Having trouble configuring google play services for Google cloud messaging 如果还使用iOS,Google Play Services 8.4.0会破坏Google Cloud Messaging for Android - Google Play Services 8.4.0 breaks Google Cloud Messaging for Android if iOS is also used 与Firebase相关的Google Play服务更新后,Android Google Cloud Messaging(GCM)令牌生成崩溃 - Android Google Cloud Messaging (GCM) token generation crash after Firebase-related Google Play Services update 适用于Android库的Google Cloud Messaging-已弃用 - Google Cloud Messaging for Android Library - Deprecated 不显示适用于Android库的Google Cloud Messaging - Not showing Google Cloud Messaging for Android Library 带有Google Cloud消息传递的android推送通知库 - android push notifications library with google cloud messaging Google云消息传递:registration_ids与设备组 - Google cloud messaging: registration_ids vs. device group 在没有 Google Play 服务的设备中使用 Firebase 云消息传递 - Using firebase cloud messaging in a device without Google Play Services Google Play游戏服务中基于套接字的消息传递与不可靠的消息传递 - Socket-based vs Unreliable messaging in Google Play Game Services
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM