public abstract class

GcmListenerService

extends Service
java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ com.google.android.gms.gcm.GcmListenerService

Class Overview

Base class for communicating with Google Cloud Messaging.

It also provides functionality such as automatically displaying notifications when requested by app server.

Override base class methods to handle any events required by the application. Methods are invoked asynchronously.

Include the following in the manifest:

 <service
     android:name=".YourGcmListenerService"
     android:exported="false" >
     <intent-filter>
         <action android:name="com.google.android.c2dm.intent.RECEIVE" />
     </intent-filter>
 </service>

Summary

[Expand]
Inherited Constants
From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2
Public Constructors
GcmListenerService()
Public Methods
void onDeletedMessages()
Called when GCM server deletes pending messages due to exceeded storage limits, for example, when the device cannot be reached for an extended period of time.
void onMessageReceived(String from, Bundle data)
Called when a message is received.
void onMessageSent(String msgId)
Called when an upstream message has been successfully sent to the GCM connection server.
void onSendError(String msgId, String error)
Called when there was an error sending an upstream message.
[Expand]
Inherited Methods
From class android.app.Service
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks2
From interface android.content.ComponentCallbacks

Public Constructors

public GcmListenerService ()

Public Methods

public void onDeletedMessages ()

Called when GCM server deletes pending messages due to exceeded storage limits, for example, when the device cannot be reached for an extended period of time.

It is recommended to retrieve any missing messages directly from the app server.

public void onMessageReceived (String from, Bundle data)

Called when a message is received.

Parameters
from String: describes message sender.
data Bundle: message data as String key/value pairs.

public void onMessageSent (String msgId)

Called when an upstream message has been successfully sent to the GCM connection server.

Parameters
msgId String: of the upstream message sent using send(String, String, Bundle).

public void onSendError (String msgId, String error)

Called when there was an error sending an upstream message.

Parameters
msgId String: of the upstream message sent using send(String, String, Bundle).
error String: description of the error.