public abstract class AbstractMpnDevice extends java.lang.Object implements MpnDeviceInterface
MpnDevice
for its concrete subclass.Constructor and Description |
---|
AbstractMpnDevice() |
Modifier and Type | Method and Description |
---|---|
void |
addListener(MpnDeviceListener listener)
Adds a listener that will receive events from the MPN device object.
The same listener can be added to several different MPN device objects. |
java.lang.String |
getApplicationId()
The application ID of this MPN device, corresponding to the package name of the application.
|
java.lang.String |
getDeviceId()
The server-side unique persistent ID of the device.
The ID is available only after the MPN device object has been successfully registered on the server. |
java.lang.String |
getDeviceToken()
The device token of this MPN device.
|
java.util.List<MpnDeviceListener> |
getListeners()
List containing the
MpnDeviceListener instances that were added to this MPN device object. |
java.lang.String |
getPreviousDeviceToken()
The previous device token of this MPN device.
|
java.lang.String |
getStatus()
The status of the device.
The status can be: UNKNOWN : when the MPN device object has just been created or deleted. |
long |
getStatusTimestamp()
The server-side timestamp of the device status.
|
boolean |
isRegistered()
Checks whether the MPN device object is currently registered on the server or not.
This flag is switched to true by server sent registration events, and back to false in case of client disconnection or server sent suspension events. |
boolean |
isSuspended()
Checks whether the MPN device object is currently suspended on the server or not.
An MPN device may be suspended if errors occur during push notification delivery. This flag is switched to true by server sent suspension events, and back to false in case of client disconnection or server sent resume events. |
void |
removeListener(MpnDeviceListener listener)
Removes a listener from the MPN device object so that it will not receive events anymore.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getPlatform
public void addListener(MpnDeviceListener listener)
addListener
in interface MpnDeviceInterface
listener
- An object that will receive the events as documented in the MpnDeviceListener
interface.removeListener(MpnDeviceListener)
public void removeListener(MpnDeviceListener listener)
removeListener
in interface MpnDeviceInterface
listener
- The listener to be removed.addListener(MpnDeviceListener)
public java.util.List<MpnDeviceListener> getListeners()
MpnDeviceListener
instances that were added to this MPN device object.getListeners
in interface MpnDeviceInterface
addListener(MpnDeviceListener)
public boolean isRegistered()
isRegistered
in interface MpnDeviceInterface
getStatus()
public boolean isSuspended()
isSuspended
in interface MpnDeviceInterface
getStatus()
@Nonnull public java.lang.String getStatus()
UNKNOWN
: when the MPN device object has just been created or deleted. In this status isRegistered()
and isSuspended()
are both false.REGISTERED
: when the MPN device object has been successfully registered on the server. In this status isRegistered()
is true and
isSuspended()
is false.SUSPENDED
: when a server error occurred while sending push notifications to this MPN device and consequently it has been suspended. In this status
isRegistered()
and isSuspended()
are both true.getStatus
in interface MpnDeviceInterface
isRegistered()
,
isSuspended()
public long getStatusTimestamp()
getStatusTimestamp
in interface MpnDeviceInterface
getStatus()
public java.lang.String getApplicationId()
MpnDevice
implementation it is determined automatically from the Application Context during creation and is used by the server as part of the device identification.getApplicationId
in interface MpnDeviceInterface
public java.lang.String getDeviceToken()
MpnDevice
implementation it is passed during creation and
is used by the server as part of the device identification.getDeviceToken
in interface MpnDeviceInterface
public java.lang.String getPreviousDeviceToken()
MpnDevice
implementation it is obtained automatically from
the Shared Preferences storage during creation and is used by the server to restore MPN subscriptions associated with this previous token. May be null if
no MPN device has been registered yet on the application.getPreviousDeviceToken
in interface MpnDeviceInterface
public java.lang.String getDeviceId()
REGISTERED
or
SUSPENDED
.getDeviceId
in interface MpnDeviceInterface