MokiManage Class Reference
Inherits from | NSObject |
Declared in | MokiManage.h |
Overview
The MokiManage SDK is designed to help developers leverage the MokiManage Platform within their own applications
Registration
Registration methods are used to manage the connection of devices to the MokiManage platform.
ASM
Application Settings Management (ASM) enables an application to have settings that are managed remotely from MokiManage. For details on the ASM structure and settings schema see the ASM Programming Guide
Custom Alerts
Custom alerts allow a developer to trigger alerts at any point in their code that get surfaced in MokiManage web interface to the appropriate admins. MokiManage already has alerts in place for things like low battery life. An example of a place where implementing a custom alert would make sense is in the application did receive memory warning delegate method.
Security
These Security methods give the developer an easy way to check for specific security vulnerablities and respond accordingly in the application.
Tasks
Delegate
-
delegate
The MokiManage library’s delegate object
property
Shared Manager
-
+ sharedManager
Returns The MokiManage shared instance
-
– initializeWithApiKey:launchingOptions:enableASM:enableAEM:asmSettingsFileName:error:
Initializes the mokimanage instance
-
– initializeWithApiKey:launchingOptions:enableASM:enableAEM:enableComplianceChecking:asmSettingsFileName:error:
Initializes the mokimanage instance
-
– apiKey
Returns your Moki Manage API Key
-
– didReceiveRemoteNotification:
Processes push notifications for MokiASM
-
– handleBackground
Handle background
-
– isReachable
Returns a boolean to indicate is a connection is available
-
– setApnsToken:
Sets the devices apns token for the library
Registration
-
– registerDevice:
Registers this device with moki manage
-
– registerDevice:withNickname:
Registers this device with moki manage
-
– silentlyRegisterDevice:
Registers this device with moki manage
-
– unregisterDevice
Unregisters this device with MokiManage
-
– registerDeviceToANewTenant:
Re-registers this device in MokiManage Dashboard with a new tenant
-
– shortCode
Returns the short code used during registration
-
– companyName
Returns the company name associated with the tenant
-
– isRegistered
Returns the device’s registration status
ASM
-
– settings
Returns a dictionary of asm settings based on your MokiASM file structure
-
– schema
Returns a dictionary of asm settings based on your MokiASM json file structure
-
– setObject:forKey:
Sets and saves an asm setting
-
– saveSettings:
Saves a dictionary of asm settings
-
– pullSettings
Pulls settings from the MokiManage Dashboard
-
– pushSettings
Pushes settings to the MokiManage Dashboard
-
– getSettingsViewController
Returns the Settings View Controller
-
– displaySettingsView:
Displays the settings views in a split pane controller
-
– arrayForKey:
Returns an array associated with the given key in the ASM settings values hash
-
– boolForKey:
Returns a boolean associated with the given key in the ASM settings values hash
-
– dataForKey:
Returns data associated with the given key in the ASM settings values hash
-
– dictionaryForKey:
Returns a dictionary associated with the given key in the ASM settings values hash
-
– floatForKey:
Returns a float associated with the given key in the ASM settings values hash
-
– integerForKey:
Returns an integer associated with the given key in the ASM settings values hash
-
– objectForKey:
Returns an object associated with the given key in the ASM settings values hash
-
– stringForKey:
Returns a string associated with the given key in the ASM settings values hash
-
– doubleForKey:
Returns a double associated with the given key in the ASM settings values hash
-
– URLForKey:
Returns a URL associated with the given key in the ASM settings values hash
-
– schemaForKey:
Returns a schema associated with the given key in the ASM settings
Custom Alerts
-
– sendAlert:
Sends an alert to the server to be displayed on the web interface
-
– sendAlert:withMessage:
Sends an alert to the server to be displayed on the web interface
-
– clearAlert:
Clears a specific alert on the web interface
Device Information
-
– addTags:
Adds an array of strings to the device object in the Moki Dashboard that are treated as tags
-
– metaData
Returns a dictionary of the meta data for the device
-
– setMetaData:
Sets meta data for the device on the device object
-
– identifierForSupport
Returns a support identifier
Security
-
– complianceReport
Returns a compliance report singleton object
-
– isJailBroken
Returns a boolean indicating the current sate of the jail broken status for the device
-
– isManaged:
Determines if the current device is under device management
-
– isSecure:
Determines if the current device is secure
-
– enabledPasswordPolicy:
Determines if the current device has a password policy enabled
-
– enabledDiskEncryption:
Determines if the current device has disk level encryption
-
– installedApps:
Returns a list of apps on the device
-
– connectedPeripherals
Returns a list of peripherals conneceted to the device
Properties
delegate
The MokiManage library’s delegate object
@property (weak, nonatomic) id<MokiManageDelegate> delegate
Discussion
The delegate receives notifications when communication with the MokiMDM server has completed.
For information about the methods you can implement for your delegate object, see protocol MokiManageDelegate.
Declared In
MokiManage.h
Class Methods
sharedManager
Returns The MokiManage shared instance
+ (MokiManage *)sharedManager
Return Value
MokiManage shared instance
Discussion
The shared manage is a singleton that allows you to initialize the manager in the app delegate and then use it throughout the applciation.
Usage [MokiManage sharedManager]
Warning: Calling methods on the shared manager before initializing it will result in unexpected errors.
Declared In
MokiManage.h
Instance Methods
URLForKey:
Returns a URL associated with the given key in the ASM settings values hash
- (NSURL *)URLForKey:(NSString *)key
Discussion
Returns the URL value for the key param in the values hash.
Usage
NSURL *value = [[MokiManage sharedManager] URLForKey:@"key"];
Declared In
MokiManage.h
addTags:
Adds an array of strings to the device object in the Moki Dashboard that are treated as tags
- (void)addTags:(NSArray *)tags
Discussion
Send the array of tags to be added to the device so the device will be included in tag based searching and scheduled actions.
Usage
[[MokiManage sharedManager] addTags:@[@"tag1", @"tag2", @"tag3"]];
Declared In
MokiManage.h
apiKey
Returns your Moki Manage API Key
- (NSString *)apiKey
Return Value
MokiManage API Key
Discussion
The unique identifier of your app within the MokiManage platform. This method will simply return the key you passed in on initialization. This method serves as a convenience method should you need it elsewhere in your application.
Usage
NSString *apiKey = [[MokiManage sharedManager] apiKey];
Declared In
MokiManage.h
arrayForKey:
Returns an array associated with the given key in the ASM settings values hash
- (NSArray *)arrayForKey:(NSString *)key
Discussion
Returns the array value for the key param in the values hash.
Usage
NSArray *values = [[MokiManage sharedManager] arrayForKey:@"key"];
Declared In
MokiManage.h
boolForKey:
Returns a boolean associated with the given key in the ASM settings values hash
- (BOOL)boolForKey:(NSString *)key
Discussion
Returns the boolean value for the key param in the values hash.
Usage
BOOL value = [[MokiManage sharedManager] boolForKey:@"key"];
Declared In
MokiManage.h
clearAlert:
Clears a specific alert on the web interface
- (void)clearAlert:(NSString *)alertId
Parameters
- alertId
The id of the alert found in the web interface
Discussion
When a alertable state is no longer alertable call clear on the alert and it will be cleared so attention isn’t drawn to resolved issues.
Usage
[[MokiManage sharedManager] clearAlert];
Declared In
MokiManage.h
companyName
Returns the company name associated with the tenant
- (NSString *)companyName
Return Value
The name of the company associated with the registered tenant. If not registered, nil is returned
Discussion
If the device is registered, company name is the name of the tenant where the device is registered.
Usage
NSString *companyName = [[MokiManage sharedManager] companyName];
Declared In
MokiManage.h
complianceReport
Returns a compliance report singleton object
- (ComplianceReport *)complianceReport
Discussion
Returns a compliance report singleton object containing the last run compliance report.
Usage
ComplianceReport *lastReport = [[MokiManage sharedManager] complianceReport];
NSDate *lastReportDateTime = [[lastReport] timestamp];
BOOL deviceIsSecurityCompliant = [[lastReport compliant] boolValue];
Declared In
MokiManage.h
connectedPeripherals
Returns a list of peripherals conneceted to the device
- (NSArray *)connectedPeripherals
Discussion
This method uses the EAAccessoryManager class to retrieve a list of accessories registered with apple
Declared In
MokiManage.h
dataForKey:
Returns data associated with the given key in the ASM settings values hash
- (NSData *)dataForKey:(NSString *)key
Discussion
Returns the data value for the key param in the values hash.
Usage
NSData *value = [[MokiManage sharedManager] dataForKey:@"key"];
Declared In
MokiManage.h
dictionaryForKey:
Returns a dictionary associated with the given key in the ASM settings values hash
- (NSDictionary *)dictionaryForKey:(NSString *)key
Discussion
Returns the dictionary value for the key param in the values hash.
Usage
NSDictionary *value = [[MokiManage sharedManager] dictionaryForKey:@"key"];
Declared In
MokiManage.h
didReceiveRemoteNotification:
Processes push notifications for MokiASM
- (void)didReceiveRemoteNotification:(NSDictionary *)userInfo
Parameters
- userInfo
The userInfo dictionary provided in application:didReceiveRemoteNotification:
Discussion
This method must be called from the application delegate whenever a push notification is received from application:didReceiveRemoteNotification:. The MokiManage SDK will process any notifications intended for it.
Usage
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *) userInfo{
[[MokiManage sharedManager] didReceiveRemoteNotification:userInfo];
}
Declared In
MokiManage.h
displaySettingsView:
Displays the settings views in a split pane controller
- (void)displaySettingsView:(id<UIApplicationDelegate>)delegate
Parameters
- UIApplicationDelegate
The main App Delegate of your application
Discussion
Split View Controllers must exist as the window root so the delate root view is swapped out for the split view controller with the settings views. When the done button is pressed the app delegate is replaced as the window root and the finishedEditingSettings delegate method is called.
Usage
[[MokiManage sharedManager] displaySettingsView:[[UIApplication sharedApplication] delegate]];
Declared In
MokiManage.h
doubleForKey:
Returns a double associated with the given key in the ASM settings values hash
- (double)doubleForKey:(NSString *)key
Discussion
Returns the double value for the key param in the values hash.
Usage
double value = [[MokiManage sharedManager] doubleForKey:@"key"];
Declared In
MokiManage.h
enabledDiskEncryption:
Determines if the current device has disk level encryption
- (void)enabledDiskEncryption:(void ( ^ ) ( BOOL result ))block
Parameters
- block
A block callback where the application can make a determination on how it should respond to the check based on the value of result
Discussion
This method takes a block as a param where the results of the method are passed for processing.
Declared In
MokiManage.h
enabledPasswordPolicy:
Determines if the current device has a password policy enabled
- (void)enabledPasswordPolicy:(void ( ^ ) ( BOOL result ))block
Parameters
- block
A block callback where the application can make a determination on how it should respond to the check based on the value of result
Discussion
This method takes a block as a param where the results of the method are passed for processing.
Declared In
MokiManage.h
floatForKey:
Returns a float associated with the given key in the ASM settings values hash
- (float)floatForKey:(NSString *)key
Discussion
Returns the float value for the key param in the values hash.
Usage
float value = [[MokiManage sharedManager] floatForKey:@"key"];
Declared In
MokiManage.h
getSettingsViewController
Returns the Settings View Controller
- (UISplitViewController *)getSettingsViewController
Return Value
The Settings View Controller
Discussion
The displaySettingsView: will get and display the settings view, in the scenario that you would like to manage its display manually, you can get the this way.
Declared In
MokiManage.h
handleBackground
Handle background
- (void)handleBackground
Discussion
This method must be called from the application delegate whenever an app enters a background state.
Declared In
MokiManage.h
identifierForSupport
Returns a support identifier
- (NSString *)identifierForSupport
Discussion
Returns the identifier that support personell can use to look up the device in the Moki Manage Dashboard. The developer should enroll a device into a tenant silently if not already enrolled and then should surface the identifier to the user for use in the support process.
Usage
NSString *identifierToShowUser = [[MokiManage sharedManager] identifierForSupport];
Declared In
MokiManage.h
initializeWithApiKey:launchingOptions:enableASM:enableAEM:asmSettingsFileName:error:
Initializes the mokimanage instance
- (void)initializeWithApiKey:(NSString *)key launchingOptions:(NSDictionary *)options enableASM:(BOOL)enableASM enableAEM:(BOOL)enableAEM asmSettingsFileName:(NSString *)fileName error:(NSError **)error
Parameters
- key
The unique identifier of your app within the MokiManage platform
- options
The options passed to the app on launch
- enableASM
A boolean specifying whether or not ASM should be used
- enableAEM
A boolean specifying whether or not AEM should be used
- error
An NSError object where errors will be reported
Return Value
Returns The MokiManage shared instance
Discussion
Initializes the mokimanage instance.
Usage
[[MokiManage sharedManager] initializeWithApiKey:appKey launchingOptions:launchOptions enableASM:YES enableAEM:YES asmSettingsFileName:nil error:&error];
Declared In
MokiManage.h
initializeWithApiKey:launchingOptions:enableASM:enableAEM:enableComplianceChecking:asmSettingsFileName:error:
Initializes the mokimanage instance
- (void)initializeWithApiKey:(NSString *)key launchingOptions:(NSDictionary *)options enableASM:(BOOL)enableASM enableAEM:(BOOL)enableAEM enableComplianceChecking:(BOOL)enableComplianceChecking asmSettingsFileName:(NSString *)fileName error:(NSError **)error
Parameters
- key
The unique identifier of your app within the MokiManage platform
- options
The options passed to the app on launch
- enableASM
A boolean specifying whether or not ASM should be used
- enableAEM
A boolean specifying whether or not AEM should be used
- enableComplianceChecking
A boolean specifying whether or not automatic compliance scans should be run and sent to the server on each heartbeat.
- error
An NSError object where errors will be reported
Return Value
Returns The MokiManage shared instance
Discussion
Initializes the mokimanage instance.
Usage
[[MokiManage sharedManager] initializeWithApiKey:appKey launchingOptions:launchOptions enableASM:YES enableAEM:YES enableComplianceChecking:YES asmSettingsFileName:nil error:&error];
Declared In
MokiManage.h
installedApps:
Returns a list of apps on the device
- (void)installedApps:(void ( ^ ) ( NSArray *result ))block
Parameters
- block
A block callback where the application can make a determination on how it should respond to the check based on the value of result
Discussion
This method takes a block as a param where the results of the method are passed for processing.
Declared In
MokiManage.h
integerForKey:
Returns an integer associated with the given key in the ASM settings values hash
- (int)integerForKey:(NSString *)key
Discussion
Returns the integer value for the key param in the values hash.
Usage
int value = [[MokiManage sharedManager] integerForKey:@"key"];
Declared In
MokiManage.h
isJailBroken
Returns a boolean indicating the current sate of the jail broken status for the device
- (BOOL)isJailBroken
Discussion
Uses 2 different techniniques to determine if the device is jail broken and returns the value to the applcation.
Declared In
MokiManage.h
isManaged:
Determines if the current device is under device management
- (void)isManaged:(void ( ^ ) ( BOOL result ))block
Parameters
- block
A block callback where the application can make a determination on how it should respond to the check based on the value of result
Discussion
This method takes a block as a param where the results of the method are passed for processing.
Usage
[[MokiManage sharedManager] isManaged:^(BOOL result) {
if(result) {
NSLog(@"Device is under MDM management");
} else {
NSLog(@"Device is not managed");
}
}
Declared In
MokiManage.h
isReachable
Returns a boolean to indicate is a connection is available
- (BOOL)isReachable
Discussion
Checks if a conection to MokiManage is available to the MokiManage server using Reachability.
Usage
if([[MokiManage sharedManager] isReachable]) {
//Send Network Request
}
Declared In
MokiManage.h
isRegistered
Returns the device’s registration status
- (BOOL)isRegistered
Return Value
The device’s registration status
Discussion
Enables the application to quickly identify whether or not the device has been registered with the MokiManage Dashboard.
Usage
if([[MokiManage sharedManager] isRegistered]) {
NSLog(@"Company Name: %@ and ShortCode: %@", [[MokiManage sharedManager] companyName], [[MokiManage sharedManager] shortCode]);
}
Declared In
MokiManage.h
isSecure:
Determines if the current device is secure
- (void)isSecure:(void ( ^ ) ( BOOL result ))block
Parameters
- block
A block callback where the application can make a determination on how it should respond to the check based on the value of result
Discussion
This method takes a block as a param where the results of the method are passed for processing.
Declared In
MokiManage.h
metaData
Returns a dictionary of the meta data for the device
- (NSDictionary *)metaData
Discussion
Returns the meta data that can then be used by the developer to identify the device is additional ways specific to your organization. The information can be updated and resaving to the device by calling setMetaData.
Usage
NSDictionary *metaData = [[MokiManage sharedManager] metaData];
Declared In
MokiManage.h
objectForKey:
Returns an object associated with the given key in the ASM settings values hash
- (id)objectForKey:(NSString *)key
Discussion
Returns the object for the key param in the values hash.
Usage
id value = [[MokiManage sharedManager] objectForKey:@"key"];
Declared In
MokiManage.h
pullSettings
Pulls settings from the MokiManage Dashboard
- (void)pullSettings
Discussion
Pulls the current setting’s values as they exist on the server to the device. This happens autmatically throught the workflow of the library, but if you ever want to trigger it manually, you can do so.
Usage
[[MokiManage sharedManager] pullSettings];
Declared In
MokiManage.h
pushSettings
Pushes settings to the MokiManage Dashboard
- (void)pushSettings
Discussion
Pushes the current setting’s values that are stored on the device to the server. This happens autmatically throught the workflow of the library, but if you ever want to trigger it manually, you can do so.
Usage
[[MokiManage sharedManager] pushSettings];
Declared In
MokiManage.h
registerDevice:
Registers this device with moki manage
- (void)registerDevice:(NSString *)shortCode
Parameters
- shortCode
Device registration shortcode obtained from the MokiManage Dashboard
Discussion
Registers this device with moki manage into the tenant associated with the given short code.
Usage
NSString *shortCode = [[self shortCodeTextField] text];
[[MokiManage sharedManager] registerDevice:shortCode];
Declared In
MokiManage.h
registerDevice:withNickname:
Registers this device with moki manage
- (void)registerDevice:(NSString *)shortCode withNickname:(NSString *)nickname
Parameters
- shortCode
Device registration shortcode obtained from the MokiManage Dashboard
- nickname
A nickname for the device that will be visible in the MokiManage Dashboard
Discussion
Registers this device with moki manage taking the users short code as params.
Usage
NSString *shortCode = [[self shortCodeTextField] text];
NSString *nickname = [[self nicknameTextField] text];
[[MokiManage sharedManager] registerDevice:shortCode withNickname:nickname];
Declared In
MokiManage.h
registerDeviceToANewTenant:
Re-registers this device in MokiManage Dashboard with a new tenant
- (void)registerDeviceToANewTenant:(NSString *)shortCode
Parameters
- shortCode
Device registration shortcode obtained from the MokiManage Dashboard
Discussion
Registers this device with moki manage under a new tenant by unregistering and re registering into the tenant associated with the given short code.
Usage
NSString *shortCode = [[self shortCodeTextField] text];
[[MokiManage sharedManager] registerDeviceToANewTenant:shortCode];
Declared In
MokiManage.h
saveSettings:
Saves a dictionary of asm settings
- (void)saveSettings:(NSDictionary *)settings
Parameters
- settings
a dictionary of asm settings
Discussion
The settings can be retrieved, modified, then passed to this save method to update the settings Saves a dictionary of asm settings.
Declared In
MokiManage.h
schema
Returns a dictionary of asm settings based on your MokiASM json file structure
- (NSDictionary *)schema
Return Value
The dictionary of asm settings schema
Discussion
The schema in its entirety is a NSDictionary representation of the settings schema json used to initialize the library.
Declared In
MokiManage.h
schemaForKey:
- (NSDictionary *)schemaForKey:(NSString *)key
Discussion
Returns the schema of associated with the given key. This differs for the other calls in that it will allow you to identify other properties about the key/value pair like Class and ComboBox options.
Usage
NSDictionary *schema = [[MokiManage sharedManager] schemaForKey:@"key"];
NSArray *classes = [schema objectForKey:@"Class"];
Declared In
MokiManage.h
sendAlert:
Sends an alert to the server to be displayed on the web interface
- (void)sendAlert:(NSString *)alertId
Parameters
- alertId
The id of the alert found in the web interface
Discussion
Sends the alert with a specific alert id that maps to the alert created on the web interface.
Usage
[[MokiManage sharedManager] sendAlert:@"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"];
Declared In
MokiManage.h
sendAlert:withMessage:
Sends an alert to the server to be displayed on the web interface
- (void)sendAlert:(NSString *)alertId withMessage:(NSString *)message
Parameters
- alertId
The id of the alert found in the web interface
- message
A custom message to display for the alert
Discussion
Sends the alert with a specific alert id that maps to the alert created on the web interface with the given message.
Usage
NSString *memoryLevel = [NSString stringWithFormat:@"Memory Level: %d", 45];
[[MokiManage sharedManager] sendAlert:@"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" withMessage:memoryLevel];
Declared In
MokiManage.h
setApnsToken:
Sets the devices apns token for the library
- (void)setApnsToken:(NSData *)token
Parameters
- token
The apsn token assigned by Apple and the os to the app
Discussion
This lets the MokiManage server know how to push to the device. This must be done in the application: didRegisterForRemoteNotificationsWithDeviceToken: delegate method.
Usage
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
[[MokiManage sharedManager] setApnsToken:deviceToken];
}
Declared In
MokiManage.h
setMetaData:
Sets meta data for the device on the device object
- (void)setMetaData:(NSDictionary *)metaData
Discussion
Sets meta data that can then be used by the developer to identify the device is additional ways specific to your organization.
Usage
[[MokiManage sharedManager] setMetaData:@{@"userId":392}];
Declared In
MokiManage.h
setObject:forKey:
Sets and saves an asm setting
- (void)setObject:(id)object forKey:(NSString *)key
Parameters
- object
The object to be saved for the key
Discussion
Calling setObject:forKey: will set the value and then push the changes to the server.
Usage NSString key = @“password”; NSString password = @“mountain29” [[MokiManage sharedManager] setObject:password forKey:key];
Declared In
MokiManage.h
settings
Returns a dictionary of asm settings based on your MokiASM file structure
- (NSDictionary *)settings
Return Value
Key/value dictionary of settings
Discussion
Once the library reads in the schema, a key/value dictionary is created with the settings values.
This dictionary is exchanged with the server for updates and is the return value for this method.
Declared In
MokiManage.h
shortCode
Returns the short code used during registration
- (NSString *)shortCode
Return Value
The short code used during registration, if none was used, nil will be returned
Discussion
If a short code was used during registration, it is available to be accessed in the application.
Usage
NSString *shortCode = [[MokiManage sharedManager] shortCode];
Declared In
MokiManage.h
silentlyRegisterDevice:
Registers this device with moki manage
- (void)silentlyRegisterDevice:(NSString *)tenantId
Parameters
- tenantId
The tenantId for a tenant in the MokiManage Dashboard
Discussion
Registers this device with moki manage with the tenant associated with the given tenant id.
Usage
Silent registration in your application will usually be done as the application is initializing for the first time. It cannot be done until the APNS token is set in the MokiManage SDK. For this reason it makes the most sense to call silent enroll after setting this value in the application didRegisterForRemoteNotifications in the App Delegate.
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
[[MokiManage sharedManager] setApnsToken:deviceToken];
[[MokiManage sharedManager] silentlyRegisterDevice:@"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"];
}
Declared In
MokiManage.h
stringForKey:
Returns a string associated with the given key in the ASM settings values hash
- (NSString *)stringForKey:(NSString *)key
Discussion
Returns the string value for the key param in the values hash.
Usage
NSString *value = [[MokiManage sharedManager] stringForKey:@"key"];
Declared In
MokiManage.h