public static interface ParsePush.IPushCallback
Note that since these are synchronous calls, it is important that they are handled fast to avoid making the app unresponsive. Intensive operations should be offloaded to a worker thread. Moreoever, any UI-related operations performed in the callbacks must be asynchronously executed on the EDT thread as follows to avoid creating a deadlock:
Display.getInstance().callSerially(new Runnable() {
public void run() {
Dialog.show("Push received (foreground)",
(pushPayload == null ? "<Null payload>" : pushPayload.toString()),
"OK",
null);
}
});
Since registration for push should 'automatically' occur in the native implementation, there's no interface method to explicitly trigger push notification registration.
Modifier and Type | Method and Description |
---|---|
void |
onAppOpenedViaPush(ca.weblite.codename1.json.JSONObject pushPayload)
Called when a 'status bar' push notification opened and the CN1 app is
currently running in the foreground.
|
boolean |
onPushReceivedBackground(ca.weblite.codename1.json.JSONObject pushPayload)
Called when a push notification is received and the CN1 app is currently
running but not in the foreground.
|
boolean |
onPushReceivedForeground(ca.weblite.codename1.json.JSONObject pushPayload)
Called when a push notification is received and the CN1 app is currently
running and in the foreground.
|
void |
onPushRegistrationFailed(ParseException error)
Called when registering for push notifications fails.
|
boolean onPushReceivedForeground(ca.weblite.codename1.json.JSONObject pushPayload)
pushPayload
- The push data.true
if the notification has been handled/consumed
and further action such as scheduling a status bar notification is
not needed. Returns false
otherwise. Notice that the exact response
to the return value is dependent on the underlying native implementation
which may change from app to app based on the requirements and
implementation choices of the app developer.boolean onPushReceivedBackground(ca.weblite.codename1.json.JSONObject pushPayload)
pushPayload
- The push data.true
if the notification has been handled/consumed
and further action such as scheduling a status bar notification is
not needed. Returns false
otherwise. Notice that the exact response
to the return value is dependent on the underlying native implementation
which may change from app to app based on the requirements and
implementation choices of the app developer.void onAppOpenedViaPush(ca.weblite.codename1.json.JSONObject pushPayload)
See related methods ParsePush.isAppOpenedViaPushNotification()
and ParsePush.getPushDataUsedToOpenApp()
for the case where
the app was not fully in the foreground with the callback was received.
pushPayload
- The push data.ParsePush.isAppOpenedViaPushNotification()
,
ParsePush.getPushDataUsedToOpenApp()
void onPushRegistrationFailed(ParseException error)
It is up to the underlying native implementation to detect when registration for push fails.
This callback should be invoked immediately if there's already a pending notification failure message.
error
- The error wrapped in a ParseException. The ()
and ParseException.getCode()
should always be filled with meaningful values.ParseException.PARSE4CN1_PUSH_REGISTRATION_FAILED
,
ParseException.PARSE4CN1_PUSH_REGISTRATION_FAILED_INSTALLATION_UPDATE_ERROR
,
ParseException.PARSE4CN1_PUSH_REGISTRATION_FAILED_MISSING_PARAMS