Class: MASPluginDevice

MASPluginDevice

The main class containing the functions for MAS Device Management.
MASPluginDevice Construtor
var MASDevice = new MASPlugin.MASDevice();

Methods

addAttribute(successHandler, errorHandler, attributeName, attributeValue)

Creates or updates a new attribute for the current device. The response is SUCCESS if attribute is added successfully, else an error occurs that specifies the reason.
Parameters:
Name Type Description
successHandler successCallbackFunction user defined success callback that is invoked on success scenario.
errorHandler errorCallbackFunction user defined error callback that is invoked on failure scenario.
attributeName string Key of the attribute to be associated with the device. Key's value should not be null or empty.
attributeValue string Value of the attribute to be associated with the device.
Source:

deregister(successHandler, errorHandler)

Deregisters a device from MAG server i.e. removes all the registration information of this device from the MAG server.
Parameters:
Name Type Description
successHandler successCallbackFunction user defined success callback that is invoked on success scenario.
errorHandler errorCallbackFunction user defined error callback that is invoked on failure scenario.
Source:

getAttribute(successHandler, errorHandler, attributeName)

Gets attribute by name, returns empty JSONObject if no attribute is found.
Sample: If k1 key exists, then the response will be : {"k1":"v1"}
Parameters:
Name Type Description
successHandler successCallbackFunction user defined success callback that is invoked on success scenario.
errorHandler errorCallbackFunction user defined error callback that is invoked on failure scenario.
attributeName string Key of the attribute to be associated with the device. Key should not be null or empty.
Source:

getAttributes(successHandler, errorHandler)

Gets all the attributes for the device, returns empty JSONArray if no attributes found.
Sample: if multiple attribute pair exists then the response will be : [{"k1":"v1"},{"k2":"v2"}]
Parameters:
Name Type Description
successHandler successCallbackFunction user defined success callback that is invoked on success scenario.
errorHandler errorCallbackFunction user defined error callback that is invoked on failure scenario.
Source:

getCurrentDevice(successHandler, errorHandler)

Fetches the device's details i.e. its registration state and identifier. The response is in a form of JSON string.
Sample : {"isRegistered":true,"identifier":"cb89kkfhhsj...jjjdj"}
Parameters:
Name Type Description
successHandler successCallbackFunction user defined success callback that is invoked on success scenario.
errorHandler errorCallbackFunction user defined error callback that is invoked on failure scenario.
Source:

getDeviceIdentifier(successHandler, errorHandler)

Fetches the device identifier registered in MAG server. The value is a string in Base64 format.
Parameters:
Name Type Description
successHandler successCallbackFunction user defined success callback that is invoked on success scenario.
errorHandler errorCallbackFunction user defined error callback that is invoked on failure scenario.
Source:

isDeviceRegistered(successHandler, errorHandler)

Verifies whether the current device is registered on MAG server
Parameters:
Name Type Description
successHandler successCallbackFunction user defined success callback that is invoked on success scenario.
errorHandler errorCallbackFunction user defined error callback that is invoked on failure scenario.
Source:

removeAllAttributes(successHandler, errorHandler)

Remove all attributes for the current device. The response is SUCCESS if all attributes removed successfully, else an error specifying the reason.
Parameters:
Name Type Description
successHandler successCallbackFunction user defined success callback that is invoked on success scenario.
errorHandler errorCallbackFunction user defined error callback that is invoked on failure scenario.
Source:

removeAttribute(successHandler, errorHandler, attributeName)

Remove attribute by name, succeed even if device attribute does not exists. The response is SUCCESS if attribute removed successfully, else an error specifying the reason.
Parameters:
Name Type Description
successHandler successCallbackFunction user defined success callback that is invoked on success scenario.
errorHandler errorCallbackFunction user defined error callback that is invoked on failure scenario.
attributeName string Key of the attribute to be associated with the device. Key's value should not be null or empty.
Source:

resetLocally(successHandler, errorHandler)

Resets all the local cache of the device for the app i.e. all tokens, credentials, states are flushed. Do not expose this API in a production app.
Parameters:
Name Type Description
successHandler successCallbackFunction user defined success callback that is invoked on success scenario.
errorHandler errorCallbackFunction user defined error callback that is invoked on failure scenario.
Source: