GcmListenerService

public abstract class GcmListenerService extends Service

This class was deprecated.
GCM is deprecated and replaced by Firebase Cloud Messaging (FCM). See the FCM migration guide for details on how to migrate to FCM.

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>

Inherited Constant Summary

Public Constructor Summary

Public Method Summary

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.

Inherited Method Summary

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 describes message sender.
data 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 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 of the upstream message sent using send(String, String, Bundle).
error description of the error.