public class MpnDevice extends AbstractMpnDevice
LightstreamerClient
in order to successfully subscribe an MPN subscription.
See MpnSubscription
.create(Context, String, MpnDeviceCreationListener)
, is also provided to obtain the device token automatically. If it succeeds,
it creates the MpnDevice object with it.LightstreamerClient.registerForMpn(MpnDeviceInterface)
method, which enables the client to subscribe MPN subscriptions and sends the device details to the
server's MPN Module, where it is assigned a permanent device ID and its state is switched to "registered".LightstreamerClient.getMpnSubscriptions(String)
method.Modifier and Type | Class and Description |
---|---|
static interface |
MpnDevice.MpnDeviceCreationListener
Interface to be implemented to receive success or failure MpnDevice creation events.
|
Constructor and Description |
---|
MpnDevice(android.content.Context appContext,
java.lang.String senderId,
java.lang.String token)
Creates an object to be used to describe an MPN device that is going to be registered to the MPN Module of Lightstreamer Server.
During creation the MpnDevice tries to acquires some more details: The package name, through the Application Context. Any previously registered device token, from the Shared Preferences storage. It then saves the current device token on the Shared Preferences storage. |
Modifier and Type | Method and Description |
---|---|
static void |
create(android.content.Context appContext,
java.lang.String senderId,
MpnDevice.MpnDeviceCreationListener listener)
Factory method that creates an MpnDevice object to be registered to the MPN Module of Lightstreamer Server.
During creation the factory method and the MpnDevice try to acquires some more details: The device token, through the Firebase Cloud Messaging APIs. The package name, through the Application Context. Any previously registered device token, from the Shared Preferences storage. The MpnDevice then saves the current device token on the Shared Preferences storage. |
java.lang.String |
getPlatform()
The platform identifier of this MPN device.
|
addListener, getApplicationId, getDeviceId, getDeviceToken, getListeners, getPreviousDeviceToken, getStatus, getStatusTimestamp, isRegistered, isSuspended, removeListener
public MpnDevice(@Nonnull android.content.Context appContext, @Nonnull java.lang.String senderId, @Nonnull java.lang.String token)
appContext
- the Application ContextsenderId
- the Sender ID (a.k.a. the Authorized Entity) as obtained from the app's project console.token
- the device tokenjava.lang.IllegalArgumentException
- if context
, senderId
or token
are null.public static void create(@Nonnull android.content.Context appContext, @Nonnull java.lang.String senderId, @Nonnull MpnDevice.MpnDeviceCreationListener listener)
MpnDevice.MpnDeviceCreationListener.onSuccess(MpnDevice)
. In case of error
MpnDevice.MpnDeviceCreationListener.onFailure(Exception)
is called.appContext
- the Application ContextsenderId
- the Sender ID (a.k.a. the Authorized Entity) as obtained from the app's project console.listener
- the MpnDevice creation listenerjava.lang.IllegalArgumentException
- if context
, senderId
or listener
are null.public java.lang.String getPlatform()
Google
and is used by the server as part of the device identification.