Back to top

Register MDM app

For the MDM client app to set or apply policies on the Gear device, you must first register the app. To register the client app, call mdm_register_client ( const char * pkg_name ) API method.

And, call the mdm_result_t mdm_get_service ( void ) API method to connect to MDM server daemon, and get the caller information.

Example:

// The package name of the app to register as an MDM client
#
define PACKAGE_NAME "org.example.wearbletutorial"
 ...
  // Register MDM client
  if (mdm_register_client(PACKAGE_NAME) == MDM_RESULT_SUCCESS) {
    // Connect to the MDM server daemon, and verify that the
    // app is authorized to get MDM client information
    if (mdm_get_service() == MDM_RESULT_SUCCESS) {
      // App is authorized; register callback
      mdm_register_client_callback(MDM_LICENSE_CB, __license_callback_, NULL, NULL);
    } else {
      // Could not connect to daemon or app is not authorized
      // to get MDM client information
      return false;
    }
  } else {
    // Failed to register the client
    return false;
  }

To de-register

Call the mdm_deregister_client ( const char * pkg_name ) API method to de-register the client app. And, call the mdm_release_service ( void ) API method to release the resources.

On this page

Is this page helpful?