airwatch-sdk-plugin
This plugin provides Cordova access to features of the AirWatch mobile device management SDK for iOS and Android.
Installation
Installation of the plugin is straightforward; simply type cordova plugin add airwatch-sdk-plugin
at the command line.
Initialization
The plugin will auto-start on both Android and iOS devices, and will automatically start the AirWatch SDK. After startup, the functions will be available in the plugins.airwatch
property of the window
object. No other initialization is required to use the functions documented below.
To receive events from the SDK, an event listener must be initialized. See "Events" below.
Functions
setSDKEventListener(listener)
- Set an event-handler function to receive events from the SDK. See "Events" below. This should be called once Cordova fires 'deviceready' event. The listener callback should have two parameters, event and info.
username(successCallback, errorCallback)
- Get the enrolled user's username. The username will be returned as a string parameter to the successCallback function.
groupId(successCallback, errorCallback)
- Get the enrolled user's group ID. The group ID will be returned as a string parameter to the successCallback function.
serverName(successCallback, errorCallback)
- Get the name of the server to which the device is enrolled. The server name will be returned as a string parameter to the successCallback function.
allowCopyPaste(successCallback, errorCallback)
- Gets the "allow copy/paste" setting for the profile: true if the user is allowed to copy and paste between managed apps, false otherwise. The value will be returned as a boolean parameter to the successCallback function.
customSettings(successCallback, errorCallback)
- Gets any custom settings provided in the app's profile. The value will be returned as a string parameter to the successCallback function.
allowOffline(successCallback, errorCallback)
- Gets the "allow offline use" setting for the profile: true if the user is allowed to use managed apps when not connected to the network, false otherwise. The value will be returned as a boolean parameter to the successCallback function.
Functions available for Android and iOS
Functions available for iOS only
Events
The AirWatch SDK sends event notifications to applications that use it when certain conditions arise. To receive these notifications in a Cordova app, the developer must first call setSDKEventListener(listener)
, where listener
is a function that accepts two parameters. The first parameter will be a string containing the name of the event, as listed below. The second will be an Object that will contain additional data if relevant to that type of event.
initSuccess
- Sent when the AirWatch SDK is successfully initialized. All the functions (See "Functions" above) of the plugin, other than
setSDKEventListener(listener)
, will be available once this event is fired. initFailure
- Sent when the AirWatch SDK cannot be successfully initialized. Any future calls to the plugin will fail.
wipe
- Sent when the device receives a "wipe" instruction from the console.
lock
- Sent when the device receives a "lock" instruction from the console.
unlock
- Sent when the device receives an "unlock" instruction from the console.
stopNetworkActivity
- Sent when the device receives a "stopNetworkActivity" instruction from the console. The event data parameter contains a property named
status
with a numeric value as specified in the table below. resumeNetworkActivity
- Sent when the device receives a "resumeNetworkActivity" instruction from the console.
Events available for Android and iOS
Events available for iOS only
stopNetworkActivity
:
Network status values for Status code | Network state |
---|---|
-2 | initializing |
-1 | normal |
0 | bad SSID |
1 | cellular data disabled |
2 | roaming |
3 | proxy failed |
4 | network not reachable |