Oracle Help Center | Oracle Push Cloud Service (Standalone) title

Listening for Callbacks

The PushIO SDK provides callbacks for certain important events. These are optional listeners that can be registered through PushIOManager and implemented for additional information about an event.

This topic describes the available listeners

 

PushIOListener

Provides the following callbacks for registration events:

void onPushIOSuccess();

void onPushIOError( String message );

 

PushIOEngagementListener

Provides the following callbacks for events related to engagements:

void onEngagementSuccess();

void onEngagementError( String error );

 

PushIONotificationServiceDiscoveryListener

Provides the following callbacks for notification service (that is, GCM/ADM) availability status:

void onNotificationServiceAvailable( String notificationServiceType );

void onNotificationServicesUnavailable( Bundle reasonExtras );

You can pass this error code to the Google Play services library to take the appropriate action (for example, prompt the user to update Google Play services framework on their device), as shown in the example below:

@Override
public void onNotificationServicesUnavailable( Bundle reasonExtras ) {
    Log.w(TAG, "No notification services detected.");
    if (reasonExtras.containsKey(PushIONotificationServiceType.GCM)) {
        final int gcmErrorCode = reasonExtras.getInt(PushIONotificationServiceType.GCM);

        if( GooglePlayServicesUtil.isUserRecoverableError(gcmErrorCode)){
            GooglePlayServicesUtil.showErrorDialogFragment(gcmErrorCode, this, 1, new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    // User cancelled dialog.
                }
            });
        }
    }
}   

You can register for these callbacks via the PushIOManager class instance.

PushIOManager pushIOManager = PushIOManager.getInstance(this);
pushIOManager.registerPushIOListener(this);
.
.
pushIOManager.ensureRegistration();

IMPORTANT: Only call ensureRegistration() after you have registered for the desired events.