1. Home
  2. SureMDM
  3. How to integrate INTENT APIs through SureMDM to communicate the Custom Properties data with third-party apps?

How to integrate INTENT APIs through SureMDM to communicate the Custom Properties data with third-party apps?

KB ID: 42G2204539
Views: 295
Updated: July 2022

If the device admin wants any third-party app to fetch a few parameters via SureMDM agent and the third party app is hosted in another portal, there are limited options where the app can fetch all the device parameters. Here is a way using our SureMDM agent, the admin can now integrate a few of the Intent APIs onto the third-party apps and have these custom properties or device properties fetched onto the third-party app.

Follow the steps mentioned below to fetch the custom properties to the approved third-party app via the SureMDM agent:

1. As a prerequisite, the following action must be declared in the manifest of the third-party app:

gears42.permission.REQUEST_CUSTOM_PROPERTIES

The third-party app must be added to the Approved apps list and custom properties can be fetched accordingly by sending a broadcast to the SureMDM agent. 

There are two ways of sending a broadcast to the SureMDM agent:

a) Sending a broadcast to fetch all the custom properties
b) Sending a broadcast to fetch the specific custom property

Sending a broadcast to fetch all the custom properties:

Please implement the below code snippet in the third-party app:

Intent lIntent = new Intent("com.gears42.action.REQUEST_CUSTOM_PROPERTIES");
lIntent.putExtra("sender_package_name", "com.example.custompropertyapp");
lIntent.setPackage("com.nix");
sendBroadcast(lIntent, "gears42.permission.REQUEST_CUSTOM_PROPERTIES");

Sending a broadcast to fetch specific custom property:

Please implement the below code snippet in the third-party app:

Intent lIntent = new Intent("com.gears42.action.REQUEST_CUSTOM_PROPERTIES");
lIntent.putExtra("sender_package_name", "com.example.custompropertyapp");
lIntent.putExtra("property_key", key);
lIntent.setPackage("com.nix");
sendBroadcast(lIntent, "gears42.permission.REQUEST_CUSTOM_PROPERTIES");

NOTE:


  • ‘Key’ will be replaced by the custom property key in the above code. For example if you want to request ‘IMEI’ or ‘Serial Number’ from a Nix agent, then the ‘key’ in the code snippet should be set to IMEI or Serial Number accordingly.


2. Once the above broadcast is sent to SureMDM Agent, it responds back by sending another broadcast to the third party-app with the required data.

3. There would be a broadcast from the SureMDM Agent to the third-party app. Use the below action associated with it.

com.gears42.action.CUSTOM_PROPERTY

4. The response format from the SureMDM agent for all the custom properties requested by the third-party app is as mentioned below:                                   

[{"dataType":"String","key":"$test$","value":"SampleValue"},
{"dataType":"String","key":"$test2$","value":"sample_value_test2"},
{"dataType":"String","key":"$serial_number$","value":"123456789"}]

5. The response format from the SureMDM agent for specific custom property requested by the third-party app is as mentioned below:

String key = extras.getString("key");
String value = extras.getString("value");
String data_type = extras.getString("data_type");

For more details on our products, click here.
If you need further assistance, submit a ticket here.

Related Articles