public interface PushListener

Receives registration, message, and error events from a PushClient.

All methods run on the Codename One EDT. The listener is retained by the client and remains active until unregistration completes. It is installed before native registration starts, so a synchronous custom transport cannot outrun the listener.

Messages received before a client is active are replayed after PushClient.register(). Operating systems may delay or suppress background and silent delivery; an application should refresh authoritative state when it resumes instead of treating push as a durable data channel.

Methods

public abstract void onRegistration(PushSubscription subscription)Called when the native provider creates or rotates a subscription.
public abstract void onMessage(PushMessage message)Called for a parsed schema-3 message.
public abstract void onError(PushError error)Called when registration or envelope processing fails.

Method details

onRegistration

public abstract void onRegistration(PushSubscription subscription)

Called when the native provider creates or rotates a subscription.

This method may run more than once during the life of an installation. Replace any previously stored token rather than assuming it is permanent.

Parameters

subscription PushSubscription
the current subscription

onMessage

public abstract void onMessage(PushMessage message)

Called for a parsed schema-3 message.

For a visible background notification, this normally runs when the user opens the notification. Foreground and silent delivery varies by platform and OS state.

Parameters

message PushMessage
the immutable message envelope

onError

public abstract void onError(PushError error)
Called when registration or envelope processing fails.

Parameters

error PushError
a stable error code, diagnostic message, and retry hint