Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class PushResult

  1. Object
  2. PushResult

What the push service answered to one CloudPush send.

Accepted means ADMITTED: the service has queued the message durably and will hand it to the providers, but no provider or device has seen it yet. Whether it arrived is reported later, through delivery feedback.

A refusal is a result too, not an exception: getStatus() says which kind (400 for a bad request, 401 for a missing or wrong key, 402 when the account doesn’t include the capability, 429 when the caller should slow down) and getError() carries the service’s explanation.

Constructors

public PushResult(int status, List<String> deliveryIds, String error, int retryAfterSeconds)A result, mostly for tests of code that sends; CloudPush makes the real ones.

Methods

public int getStatus()
public boolean isAccepted()
public List<String> getDeliveryIds()One id per target the service admitted, for matching delivery feedback later.
public String getError()
public int getRetryAfterSeconds()How long a 429 asked the caller to wait.
public String toString()Returns a string representation of the object.

Inherited methods

Constructor details

PushResult

public PushResult(int status, List<String> deliveryIds, String error, int retryAfterSeconds)
A result, mostly for tests of code that sends; CloudPush makes the real ones.

Parameters

status int
the HTTP status
deliveryIds List<String>
the delivery ids, or null for none
error String
the service’s error text, or null
retryAfterSeconds int
the seconds to wait before retrying, or -1

Method details

getStatus

public int getStatus()

Returns

the HTTP status the service answered with

isAccepted

public boolean isAccepted()

Returns

true when the service admitted the message (202, or any 2xx)

getDeliveryIds

public List<String> getDeliveryIds()
One id per target the service admitted, for matching delivery feedback later.

Returns

the ids, empty when there are none; never null

getError

public String getError()

Returns

the service’s explanation of a refusal, or null when it was accepted

getRetryAfterSeconds

public int getRetryAfterSeconds()
How long a 429 asked the caller to wait.

Returns

seconds from the Retry-After header, or -1 when there was none

toString

public String toString()
Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + ‘@’ + Integer.toHexString(hashCode())