public class DeviceProvisioningManager
extends java.lang.Object
implements android.arch.lifecycle.LifecycleObserver
DeviceProvisioningManager class collects all of the use cases related to device
provisioning, such as mobile phone number enrollment and verification, in order to increase
badge security. In addition, this class also includes the
request(int, CompleteCallback) method so that the user can request a mobile phone number
verification code to the phone number enrolled to the badge ID.
When device provisioning is configured through Network Manager, a user is expected to enroll a
mobile phone number with the badge before the grace period (found in
OrgConfigEntity.phoneNumberGracePeriod()) has passed. When the grace period has passed,
the badge will become inactive until a mobile phone number is enrolled with the badge.
To enroll a mobile phone number, call enroll(int, String, CompleteCallback)
and specify the badge ID as well as the mobile phone number you would like to enroll with the
badge. After the callback returns with an CompleteCallback.onComplete() status, the
device enrolled with the mobile phone number will receive a 6-digit verification code.
Then, to prove ownership of the mobile phone number you have enrolled, call
verify(int, String, CompleteCallback) with the badge ID and the 6-digit
verification code sent to the mobile phone number. Please note: if you skip the verification
step, your badge will still have the
BadgeEntity.Status.PENDING_PHONE_NUMBER_ENROLLMENT status.
After a mobile phone number is enrolled, the badge will be required to perform mobile phone
number verification each time it is installed on a new device to fully activate the badge.
Otherwise, the status of badge will be
BadgeEntity.Status.PENDING_PHONE_NUMBER_VERIFICATION. In addition, calling
BadgeModel.pendingBadgeConditionList() will return a BadgeCondition
with BadgeCondition.getType() equal to
BadgeCondition.TYPE_DEVICE_PROVISION_VERIFICATION.
To activate the badge on a new device, first call request(int, CompleteCallback) to
request a 6-digit verification code for the mobile phone number associated with the badge ID.
Then, call verify(int, String, CompleteCallback) to confirm the 6-digit verification
code and activate the badge on the device.
To revoke the badge on other devices, please refer to DeviceManager for guidance.
| Constructor and Description |
|---|
DeviceProvisioningManager(android.support.v7.app.AppCompatActivity appCompatActivity)
Constructor for an
DeviceProvisioningManager object with the lifecycle set. |
DeviceProvisioningManager(android.support.v4.app.Fragment fragment)
Constructor for an
DeviceProvisioningManager object with the lifecycle set. |
DeviceProvisioningManager(android.arch.lifecycle.Lifecycle lifecycle)
Constructor for an
DeviceProvisioningManager object with the lifecycle set. |
| Modifier and Type | Method and Description |
|---|---|
void |
enroll(int badgeId,
java.lang.String phoneNumber,
CompleteCallback callback)
Returns a
CompleteCallback after enrolling a mobile phone number with the given badge
ID. |
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 |
verify(int badgeId,
java.lang.String codeToBeVerified,
CompleteCallback callback)
Returns a
CompleteCallback after verifying the 6-digit verification code sent to the
mobile phone number enrolled with the badge. |
public DeviceProvisioningManager(android.arch.lifecycle.Lifecycle lifecycle)
DeviceProvisioningManager object with the lifecycle set.lifecycle - See Lifecyclepublic DeviceProvisioningManager(android.support.v7.app.AppCompatActivity appCompatActivity)
DeviceProvisioningManager object with the lifecycle set.appCompatActivity - See AppCompatActivitypublic DeviceProvisioningManager(android.support.v4.app.Fragment fragment)
DeviceProvisioningManager object with the lifecycle set.fragment - See Fragmentpublic void enroll(int badgeId,
java.lang.String phoneNumber,
CompleteCallback callback)
CompleteCallback after enrolling a mobile phone number with the given badge
ID. Will send a 6-digit verification code to the mobile phone number afterwards.badgeId - the identification number of the badgephoneNumber - the mobile phone number of the user with country code prefixedcallback - the callback to receive the result of enrolling a mobile phone number
with the given badge IDpublic 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 activate
the badge with the code by calling verify(int, String, CompleteCallback).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 IDverify(int, String, CompleteCallback)public void verify(int badgeId,
java.lang.String codeToBeVerified,
CompleteCallback callback)
CompleteCallback after verifying the 6-digit verification code sent to the
mobile phone number enrolled with the badge. If the correct verification code is entered for
a specific badge ID, then that badge will be activated. Subsequently, the badge will update
its information and its keys will be refreshed.badgeId - the identification number of the badgecodeToBeVerified - the verification codecallback - the callback to receive the result of verifying the 6-digit
verification code sent to the mobile phone number enrolled with the
badge