public class

GCMPush

extends AbstractPush
java.lang.Object
   ↳ com.kinvey.android.push.AbstractPush
     ↳ com.kinvey.android.push.GCMPush

Class Overview

This functionality can be accessed through the push() convenience method.

This class manages GCM Push for the current logged in user. Use `gcm.enabled=true` in the `kinvey.properties` file to enable GCM.

sample usage:
     kinveyClient.push().initialize(getApplicationContext());
 

This code snippet will enable push notifications through GCM for the current logged in user.

Summary

Nested Classes
class GCMPush.PushConfig This class is used to maintain metadata about the current GCM push configuration in the User collection. 
class GCMPush.PushConfigField Manages ids and notificationKeys for PushConfig  
[Expand]
Inherited Constants
From class com.kinvey.android.push.AbstractPush
Fields
public static String[] senderIDs
[Expand]
Inherited Fields
From class com.kinvey.android.push.AbstractPush
Public Constructors
GCMPush(Client client, boolean inProduction, String... senderIDs)
Public Methods
void disablePush()
Unregisters the current user with GCM and removes all _push fields from the current user object.
String getPushId()
Get the Registration ID from GCM for the Client's current application context.
String[] getSenderIDs()
Get a list of all sender IDs as an array
GCMPush initialize(Application currentApp)
Initialize GCM by registering the current user with both GCM as well as your backend at Kinvey.
GCMPush initialize(PushOptions options, Application currentApp)
Initialize GCM by registering the current user with both GCM as well as your backend at Kinvey.
boolean isInProduction()
Is GCM Push configured for production or a dev environment?
boolean isPushEnabled()
Check to see if the current user is registered for GCM.
[Expand]
Inherited Methods
From class com.kinvey.android.push.AbstractPush
From class java.lang.Object

Fields

public static String[] senderIDs

Public Constructors

public GCMPush (Client client, boolean inProduction, String... senderIDs)

Public Methods

public void disablePush ()

Unregisters the current user with GCM and removes all _push fields from the current user object. Unregistration is asynchronous, so use the `KinveyGCMService` to receive notification when unregistration has completed.

public String getPushId ()

Get the Registration ID from GCM for the Client's current application context. Note if the current user is not registered, the registration ID will be an empty string.

Returns
  • - the current user's GCM registration ID or an empty string ""

public String[] getSenderIDs ()

Get a list of all sender IDs as an array

Returns
  • an array of sender IDs

public GCMPush initialize (Application currentApp)

Initialize GCM by registering the current user with both GCM as well as your backend at Kinvey. Note these operations are performed asynchronously, however there is no callback. Instead, updates are delegated to your custom `KinveyGCMService` which will handle any responses.

Parameters
currentApp - The current valid application context.
Returns
  • an instance of GCM push, initialized for the current user.

public GCMPush initialize (PushOptions options, Application currentApp)

Initialize GCM by registering the current user with both GCM as well as your backend at Kinvey. Note these operations are performed asynchronously, however there is no callback. Instead, updates are delegated to your custom `KinveyGCMService` which will handle any responses.

Parameters
options - deprecated, pass null.
currentApp - The current valid application context.
Returns
  • an instance of GCM push, initialized for the current user.

public boolean isInProduction ()

Is GCM Push configured for production or a dev environment?

Returns
  • true if in production mode, false if not

public boolean isPushEnabled ()

Check to see if the current user is registered for GCM. This checks both with GCM directly as well as with a Kinvey backend. As registration occurs asynchronously, ensure your `KinveyGCMService` has received the onRegister call first.

Returns
  • true if current user is registered, false if they are not.