Custom Remote Commands

What are Custom Remote Commands?

Custom remote commands are just like Mason’s provided remote command functionality like Ping, Locate, and Reboot but added by you. Adding custom commands allows you to extend the functionality of the Mason Console giving full autonomy to you and your team.

Remote Commands leverage our Push Notification infrastructure allowing near real time commands to be sent directly to your applications. Currently these commands have a 30 day time to live, so as long as your device is connected to the internet or connects within 30days it will receive the command.

Creating a Custom Remote Command

You can create a custom Remote command directly from the Device Details screen within the Mason Console by selecting the “ADD YOUR OWN” button under the Remote Commands section.

Device Details

Upon selection of the “ADD YOUR OWN” button a form will be shown allowing you to add a label and tool tip for your custom button. Additionally you’re must specify an application to send your remote command to.

New Command Form

Finally, give the command a unique name to be interpreted by your application such as REBOOT_APPLICATION or UPLOAD_DATA. Optional arguments can be passed as well in a comma separated list. Then hit save!

Integrating your Application

You can start receiving your custom remote commands on a device by making 2 changes to your application. First, declare a broadcast receiver in your manifest with the Mason permission: AndroidManifest.xml:

      <!-- Do not modify this -->
      <action android:name="com.bymason.platform.core.action.PUSH_RECEIVE"/>

Next, create your receiver where you’ll handle incoming events from the Mason Platform.

public class PushReceiver extends BroadcastReceiver {
  private static final String TAG = "PushReceiver";
  public void onReceive(Context context, Intent intent) {
    if (intent != null) {
      String command = intent.getStringExtra("com.bymason.platform.core.extra.PUSH_COMMAND");
      String[] args = intent.getStringArrayExtra("com.bymason.platform.core.extra.PUSH_ARGS");
      String message = "Command: " + command + "\n" + "args: " + Arrays.toString(args);
      Toast.makeText(context, message, Toast.LENGTH_LONG).show();

That’s it! Now you can build custom remote functionality into your app that can be controlled from the Mason Console.