Android SDK - Google Cloud Messaging Utility Module

DOCS

Last updated: Aug 15th, 7:18am

The Google Cloud Messaging utility enables the Android app developer to use the Google Cloud Messaging (GCM) service to display notification messages to the user about the mobile wallet app, even when the app is not currently active (that is, in the background or not logged-in). For example, messages that might be pushed to a user include notifications about an available software update; new available offers, new store locations in a subscribed geo-location, approaching payment account expiration, and other similar events.

Also, when a user re-links a previously unlinked device or links a new device to an existing account, the app must prompt the user again to enable push notifications and invoke the corresponding method based on the response.

To implement GCM notifications, developers must ensure that the device is registered with GCM connection servers to receive messaging, and also registered to accept messages specifically from the WLW service.

The services exposed in the device info module are located in the following package classes:

ItemDescription
UI Servicecom.paydiant.android.ui.service.gcm.GCMUtilityService
Core Servicecom.paydiant.android.core.facade.PaydiantGCMUtilityFacade

Add GCM Services to Android Manifest File

To invoke the GCM services to register and unregister a device for GCM notifications, add the relevant permission classes to the Android Manifest File for your SDK instance. The following sample shows the required insertion to the AndroidManifest.xml file.

    1< ?xml version="1.0" encoding="utf-8"? >
    2< manifest xmlns:android="http://schemas.android.com/apk/res/android" ... >
    3...
    4< uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" / >
    5< uses-permission android:name="<your package name>.permission.C2D_MESSAGE" / >
    6< uses-permission android:name="android.permission.GET_ACCOUNTS" / >
    7< uses-permission android:name="android.permission.WAKE_LOCK" / >
    8< permission android:name="< your package name >.permission.C2D_MESSAGE"
    9 android:protectionLevel="signature" / >
    10< uses-permission android:name="<your package name>.permission.C2D_MESSAGE" / >
    11< /manifest >

    Set UI Package GCM Service Listeners

    To invoke the callback methods returned by the WLW service in response to the methods invoked by the GCM utility module of the SDK, set an implementation of the listener interface in the UI Service class.

    ItemDescription
    UI Servicecom.paydiant.android.ui.service.gcm.IGCMUtilityServiceListener
    or an overridden instance of:

    com.paydiant.android.ui.service.gcm.GCMUtilityServiceListenerAdapter
    Set Listenervoid setGCMUtilityServiceListener(IGCMUtilityServiceListener listener);
    Remove Listenervoid removeListener();
    Call this method to remove the device info listener and set it to null.

    Check Current Device Registration

    This method checks the registration status of the device with respect to receiving GCM notifications from WLW.

    Note: This method does not check whether the device is enabled for GCM message notifications, only whether the device is subscribed to receive messages from WLW.

    ItemDescription
    UI Methodpublic void isRegisteredWithPaydiant ();
    Successvoid onIsRegisteredWithPaydiantSuccess(boolean status);

    TRUE if the device already has a valid registration ID
    FALSE if no record of registration is detected.
    Failurevoid onGMCUtilityServiceError(PaydiantException e)

    The failure callback returns an instance of PaydiantException detailing the nature of the failure and the relevant errors as they relate to the GCM_CHECK_REGISTRATION_EVENT.
    Core Methodpublic boolean isRegisteredForGCM ();

    Returns raw output

    Errors

    When checking the device messaging registration status, the following errors are applicable for the GCM_CHECK_REGISTRATION_EVENT:

    ErrorDescription
    403Access to the server is prohibited because the user is not logged-in.
    500An unknown error occurred internally in the server.

    Register for GCM and WLW Messaging

    Invoke this method from the UI service package to register the device with GCM connection servers, then automatically use the registration id returned to complete the WLW messaging registration. This method is not available in the Core package.

    ItemDescription
    UI Methodpublic void register(String senderId);
    ParameterssenderId - The caller’s unique identifier when accessing the Google API console.
    Successvoid onRegistrationSuccess(String registrationId);

    The success callback returns the registrationId that was generated by the GCM service to confirm the registration.
    Failurevoid onGMCUtilityServiceError(PaydiantException e)

    The failure callback returns an instance of PaydiantException detailing the nature of the failure and the relevant errors as they relate to the GCM_REGISTRATION_EVENT.
    Core MethodThere is no Core implementation for this call.

    Errors

    When checking the device messaging registration status, the following errors are applicable for the GCM_REGISTRATION_EVENT:

    ErrorDescription
    400Could not register the device due to invalid parameters in the request.
    403Access to the server is prohibited because the user is not logged-in.
    500An unknown error occurred internally in the server.
    GCM ERROR_INVALID_SENDERError message passed from Google’s Cloud Messaging service.
    GCM ERROR_SERVICE_NOT_AVAILABLEError message passed from Google’s Cloud Messaging service.
    GCM ERROR_INVALID_PARAMETERSError message passed from Google’s Cloud Messaging service.

    Register for WLW Messaging

    If the device is already registered with the GCM service, invoke this method from the core or UI service package to register for messaging from the WLW service.

    ItemDescription
    UI Methodpublic void registerWithPaydiant (String registrationId);
    ParametersregistrationId - The ID returned by the GCM service to confirm registration.
    Successvoid onRegistrationWithPaydiantSuccess();

    The success callback returns no additional parameters.
    Failurevoid onGMCUtilityServiceError(PaydiantException e)

    The failure callback returns an instance of PaydiantException detailing the nature of the failure and the relevant errors as they relate to the GCM_REGISTRATION_WITH_PAYDIANT_EVENT.
    Core Methodpublic void registerForGCM (String registrationId);
    ParametersregistrationId - The ID returned by the GCM service to confirm registration.

    Errors

    When checking the device messaging registration status, the following errors are applicable for the GCM_REGISTRATION_WITH_PAYDIANT_EVENT:

    ErrorDescription
    400Could not update device properties due to invalid parameters in the request.
    403Access to the server is prohibited because the user is not logged-in.
    500An unknown error occurred internally in the server.

    Disable Messaging from WLW

    Invoke this method to unsubscribe the device from receiving messages from the WLW service. This method does NOT disable the overall GCM registration.

    Note: Before invoking this call, check whether the device is currently registered to receive messages from WLW (see Check Current Device Registration). Calling this method for an already unregistered device will return an exception.

    ItemDescription
    UI Methodpublic void unregisterFromPaydiant();
    Successvoid onUnregistrationWithPaydiantSuccess();

    The success callback returns no additional parameters.
    Failurevoid onGMCUtilityServiceError(PaydiantException e)

    The failure callback returns an instance of PaydiantException detailing the nature of the failure and the relevant errors as they relate to the GCM_UNREGISTER_WITH_PAYDIANT_EVENT.
    Core Methodpublic void unregister ();

    Errors

    When checking the device messaging registration status, the following errors are applicable for the GCM_UNREGISTER_WITH_PAYDIANT_EVENT:

    ErrorDescription
    403Access to the server is prohibited because the user is not logged-in.
    400Can’t unregister because no registration exists.
    500An unknown error occurred internally in the server.

    Disable Messaging from GCM and WLW

    Invoke this method to disconnect the device’s from messaging registration with both GCM servers and the WLW service.

    ItemDescription
    UI Methodpublic void unregister();
    Successvoid onUnregistrationSuccess();

    The success callback returns no additional parameters.
    Failurevoid onGMCUtilityServiceError(PaydiantException e)

    The failure callback returns an instance of PaydiantException detailing the nature of the failure and the relevant errors as they relate to the GCM_UNREGISTER_EVENT.
    Core MethodThe Core implementation is not available for this call.

    Errors

    When checking the device messaging registration status, the following errors are applicable for the GCM_UNREGISTER_EVENT:

    ErrorDescription
    403Access to the server is prohibited because the user is not logged-in.
    500An unknown error occurred internally in the server.
    GCM ERROR_INVALID_SENDERError message passed from Google’s Cloud Messaging service
    GCM ERROR_SERVICE_NOT_AVAILABLEError message passed from Google’s Cloud Messaging service