14

Current Google GCM documentation requires you to install Google Play Services and to use them for GCM (Google Cloud Messaging). The library is 1.1MB, yet my current .apk is half that size. 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.

SDK Manager allows download and installation of standalone Google Cloud Messaging for Android package. It is the one that was used before Google I/O 2013, where Play Services were announced.

My question is: what is the difference in performance between GPS's GCM and standalone GCM for Android? Do I really have to switch to GPS? Is standalone GCM depricated? Can I still receive data (up to 4K) with standalone GCM?

Xeos
  • 5,975
  • 11
  • 50
  • 79

5 Answers5

9

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.

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. Yes, your APK will be a little bit bigger, but I think it's worth it.

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.

luthier
  • 2,674
  • 4
  • 32
  • 35
  • My question may sound stupid, but please tell me how to send notifications? I have read some tutorials http://techlovejump.in/2013/11/android-push-notification-using-google-cloud-messaging-gcm-php-google-play-service-library/ in which php files are created, but where to keep them? How will android app communicate with those files? – android_newbie Dec 08 '13 at 08:39
  • http://rmarcejaeger.com/2015/09/18/tutorial-how-to-implement-push-notifications-using-google-cloud-messaging-for-android-part-1-client-app – Kyaw Min Thu L Mar 24 '16 at 02:15
3

The old GCM though deprecated, still works. 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. 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. Bottom Line : Seems you can use the old GCM method for the time being.

tony9099
  • 4,567
  • 9
  • 44
  • 73
1

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.

Description of The Google Play services client library mentions

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.

I haven't myself measured the difference in apk with the two different approaches. Will update if I do.

Atul Goyal
  • 3,511
  • 5
  • 39
  • 59
  • 1
    It's not just the APK size. It's the sheer number of method references in GPS (nearly 11000). If you have a large app (as we do) this can cause your app to no longer build into a single DEX file – dkneller Jan 30 '15 at 18:29
  • 1
    Play services 6.5 solves that problem. Take a look here: http://android-developers.blogspot.in/2014/11/google-play-services-65.html – Atul Goyal Feb 03 '15 at 09:15
  • I'm not sure it solves the problem. As we're using an ANT build still and there haven't been updates to break out the library into subset libraries (in the SDK) there is still may be issues. It looks like the subset libraries are Maven artifacts so I'm going to see if we can manage them with Maven in which case it may be a solution, depending on how small the basic GCM implementation is – dkneller Feb 11 '15 at 02:36
0

the new GCM method also uses the GcmIntentService where stays the handle configuration for received message and where i configured my sendNotification(msg) method

  • "When a GCM connection server delivers the message to your client app, the BroadcastReceiver receives the message as an intent. You can either process the intent in the BroadcastReceiver, or you can pass off the work of processing the intent to a service (typically, an IntentService). If you use a service, your broadcast receiver should be an instance of WakefulBroadcastReceiver, to hold a wake lock while the service is doing its work." http://developer.android.com/reference/com/google/android/gms/gcm/GoogleCloudMessaging.html –  Sep 26 '13 at 09:08
  • 1
    [New Google recommendation](https://developers.google.com/cloud-messaging/android/client) is to replace `WakefulBroadcastReceiver` by `GCMReceiver` and `GcmListenerService`. – Alexander Farber Aug 16 '15 at 08:32
-1

Check the device to make sure it has the Google Play Services 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.

It will save you from project memory size.

Ajay Takur
  • 6,079
  • 5
  • 39
  • 55
  • This doesn't matter to your APK size. As always the APK is compiled against a stub implementation with linking against the actual library on the device (either already there, or downloadable). – dkneller Jan 30 '15 at 18:31