public class DeviceManager
extends java.lang.Object
implements android.arch.lifecycle.LifecycleObserver
DeviceManager class takes care of the responsibilities of managing badges across
all devices. Device management includes processes such as listing all badges on the current
device, listing all devices that have a specific badge installed, and revoking a badge on a
device. All of these methods will be executed on a background thread and return the result on the
main thread. To receive the result, you are expected to pass a corresponding
SingleCallback or CompleteCallback.
To list all devices that have a specific badge installed, call
list(int, SingleCallback). With the List of
DeviceBadgeItem objects, you can revoke a badge on a device by specifying the
BadgeEntity.badgeId() and the device UUID found in the
DeviceBadgeItem.deviceEntity()}.
To list all devices that have installed any badge on the current device, call
list(SingleCallback). The result will be encapsulated in a List of
DeviceModel objects. With this list of devices, you can revoke the badge on a specific
device through revoke(int, String, CompleteCallback). If the badge requires
mobile phone number verification before being revoked,
CompleteCallback.onError(DomainException) will be called with the error code
DomainException.DEVICE_PROVISION_REQUIRED. Then, the phone registered with the mobile
phone number will automatically receive the device provisioning code for deactivation. With the
code, you can resume revoking the badge by calling
revoke(int, String, String, CompleteCallback).
This class also includes clear(CompleteCallback), which is used to delete all badge
information on the device from both the server and the cache. Once this is performed, badge
recovery will be required to use the badge on the current device.
| Constructor and Description |
|---|
DeviceManager(android.support.v7.app.AppCompatActivity appCompatActivity)
Constructor for an
DeviceManager object with the lifecycle set. |
DeviceManager(android.support.v4.app.Fragment fragment)
Constructor for an
DeviceManager object with the lifecycle set. |
DeviceManager(android.arch.lifecycle.Lifecycle lifecycle)
Constructor for an
DeviceManager object with the lifecycle set. |
| Modifier and Type | Method and Description |
|---|---|
void |
clear(CompleteCallback callback)
Returns a
CompleteCallback after clearing all of the badges on the current device
from both the server and cache. |
void |
get(java.lang.String deviceUuid,
SingleCallback<DeviceModel> callback)
Returns the
DeviceModel object that contains the
DeviceBadgeItem.deviceEntity() object and the List of
DeviceBadgeModel objects on the given device. |
void |
list(int badgeId,
SingleCallback<java.util.List<DeviceBadgeItem>> callback)
Returns the
List of DeviceBadgeItem objects that have a specific badge
installed. |
void |
list(SingleCallback<java.util.List<DeviceModel>> callback)
Returns the
List of DeviceModel objects that have installed any of the
badges on the current device. |
void |
request(int badgeId,
CompleteCallback callback)
Returns a
CompleteCallback after requesting a 6-digit verification code to be sent to
the mobile phone number associated with the badge ID, found at
BadgeUIEntity.defaultEnrolledPhoneNumber(). |
void |
revoke(int badgeId,
java.lang.String deviceUuid,
CompleteCallback callback)
Returns a
CompleteCallback after revoking a badge on a specific device, given the
device UUID from DeviceBadgeItem.deviceEntity()}. |
void |
revoke(int badgeId,
java.lang.String deviceUuid,
java.lang.String code,
CompleteCallback callback)
Returns a
CompleteCallback after revoking a badge that requires mobile phone number
verification on a specific device, given the device UUID from
DeviceBadgeItem.deviceEntity()} and the device provisioning deactivation code sent to
the phone. |
public DeviceManager(android.arch.lifecycle.Lifecycle lifecycle)
DeviceManager object with the lifecycle set.lifecycle - See Lifecyclepublic DeviceManager(android.support.v7.app.AppCompatActivity appCompatActivity)
DeviceManager object with the lifecycle set.appCompatActivity - See AppCompatActivitypublic DeviceManager(android.support.v4.app.Fragment fragment)
DeviceManager object with the lifecycle set.fragment - See Fragmentpublic void clear(CompleteCallback callback)
CompleteCallback after clearing all of the badges on the current device
from both the server and cache. Badge recovery is required to access the badge again.callback - the callback to receive the result of clearing all of the badges on
the current devicepublic void get(@Nullable
java.lang.String deviceUuid,
SingleCallback<DeviceModel> callback)
DeviceModel object that contains the
DeviceBadgeItem.deviceEntity() object and the List of
DeviceBadgeModel objects on the given device.deviceUuid - the universally unique identifier (UUID) of the device. May be null
if you want to get the current devicecallback - the callback to receive the DeviceModel objectpublic void list(SingleCallback<java.util.List<DeviceModel>> callback)
List of DeviceModel objects that have installed any of the
badges on the current device.callback - the callback to receive a list of DeviceModel objectslist(int, SingleCallback)public void list(int badgeId,
SingleCallback<java.util.List<DeviceBadgeItem>> callback)
List of DeviceBadgeItem objects that have a specific badge
installed.badgeId - the identification number of the badge to be queriedcallback - the callback to receive a list of DeviceBadgeItem objectslist(SingleCallback)public void request(int badgeId,
CompleteCallback callback)
CompleteCallback after requesting a 6-digit verification code to be sent to
the mobile phone number associated with the badge ID, found at
BadgeUIEntity.defaultEnrolledPhoneNumber(). After the code is sent, you can
deactivate the badge with the code by calling
revoke(int, String, String, CompleteCallback). This is only required for badges that
require device provisioning.badgeId - the identification number of the badgecallback - the callback after requesting a 6-digit verification code to be sent to the
mobile phone number associated with the badge IDto remove a badge with device
provisioning,
to remove a badge without device provisioningpublic void revoke(int badgeId,
java.lang.String deviceUuid,
CompleteCallback callback)
CompleteCallback after revoking a badge on a specific device, given the
device UUID from DeviceBadgeItem.deviceEntity()}. You can get the List of
DeviceBadgeItem objects that have a specific badge installed by calling
list(int, SingleCallback).badgeId - the identification number of the badgedeviceUuid - the universally unique identifier (UUID) of the devicecallback - the callback to receive the result of revoking a badge on the given devicerevoke(int, String, String, CompleteCallback)public void revoke(int badgeId,
java.lang.String deviceUuid,
java.lang.String code,
CompleteCallback callback)
CompleteCallback after revoking a badge that requires mobile phone number
verification on a specific device, given the device UUID from
DeviceBadgeItem.deviceEntity()} and the device provisioning deactivation code sent to
the phone.badgeId - the identification number of the badgedeviceUuid - the universally unique identifier (UUID) of the devicecode - the device provisioning deactivation code sent to the mobile phone number
enrolled with the badgecallback - the callback to receive the result of revoking a badge that requires mobile
phone number verification on a specific devicerevoke(int, String, CompleteCallback)