0

Follow the guid in gcm quick start, I successfully configure the GCM demo, and I can get the push message from the server(GcmSender.java). From the structure of the project "app", I can see 5 class:

MainActivity.java

MyGcmListenerService.java

MyInstanceIDListenerService.java

QuickstartPreferences.java

RegistrationIntentService.java

But I can not find where the client build the TCP connection with the GCM server, therefore I do not understand why the client can receive the GCM message?

1
  • 2
    GCM relies on Google Play Services. Google maintains the persistent connections to devices through that, which lives in another process on the device. That process received the push message and federates it to the proper app. Hence your app does not need to build any connection.
    – Karakuri
    Jul 7, 2015 at 3:41

1 Answer 1

0

We don't need to worry about TCP connection because that is handled by GCM server , Our Application Server and Google Play Services

We recive message because we have BroadcastReceiver

See below explanation

Push notifications let your application notify a user of new messages or events even when the user is not actively using your application. On Android devices, when a device receives a push notification, your application's icon and a message appear in the status bar.

See this tutorial for complete GCM tutorial

2
  • Does that mean when GCM server send a message to my app, the google play service receive first and then it send a broadcast to let my app receive it?
    – wqycsu
    Jul 7, 2015 at 6:38
  • yes . Then your BrodcastReciver will catch that and you can do what you want to do in OnRecive method
    – N J
    Jul 7, 2015 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.