Skip to content
Try for free

ThingsBoard Cloud

Choose your data region

Your data stays in the region you choose, for residency and compliance. No credit card required.

Rather run it yourself? Install on your own servers

Configure mobile actions in ThingsBoard Mobile Application

Mobile actions are a special subtype of widget actions that let you trigger native device functions — take a photo, scan a QR code, get the phone’s location, make a phone call, and more. The result of each action is passed to a JavaScript function you configure, so you can process it further — for example, save a photo as an entity attribute or use a scanned QR code to claim a device.

  1. Go to Dashboard groups in the left main menu.
  2. Open the target dashboard group.
  3. Click the dashboard you want to modify.
  4. In the dashboard details panel, click Open dashboard.
  5. Click the Edit (pencil) button in the bottom-right corner to enter edit mode.
  6. Click the Edit (pencil) icon on the target widget to open its settings.
  7. Navigate to the Actions tab.
  8. Click + to add a new action.
  9. In the Type drop-down, select Mobile action.
  10. In the Mobile action type drop-down, select the action type you want.
  11. Configure the JavaScript function with your processing logic. Use the help buttons for function definitions and examples.

Opens the device image gallery so you can select a photo. Returns the selected image as a base64 data URL.

Configure the processImage function to handle the result — for example, store the image as an entity attribute to display it later in widgets.

Opens the device camera to capture a photo. Returns the captured image as a base64 data URL.

Configure the processImage function to handle the result.

Takes a location in latitude/longitude format and opens the available maps app to show directions to that location.

Configure the getLocation function to extract latitude/longitude from entity attributes — for example, to direct you to a field device’s location.

Takes a location in latitude/longitude format and opens the available maps app to display that location on the map.

Configure the getLocation function to extract coordinates from entity attributes.

Opens the QR code scanner. Returns the scanned value.

Configure the processQrCode function to process the result. A common use case is device claiming — the QR code encodes the device name and secret key, which are then used to claim the device. For details, see Claiming devices.

Takes a phone number and opens the appropriate app to initiate a call.

Configure the getPhoneNumber function to extract the number from entity attributes.

Reads the current device location from location services. Returns a latitude/longitude pair.

Configure the processLocation function to handle the result — for example, save the coordinates as entity attributes to update the entity’s position on a map widget.

Turn on Save location to entity to have the platform write the coordinates for you, instead of doing it yourself in the function. You then pick a target entity and the data keys to save under, and the function still runs afterwards — with the name of the entity the location was saved to. See Location tracking.

Start live location tracking

Section titled Start live location tracking

Starts a background GPS tracking session. Unlike Get phone location, which reads one position and finishes, a session keeps streaming fixes and saving each one to the target entity until it is stopped.

The dashboard resolves the target entity, the data keys and the session limits up front, so the app has everything it needs and never looks anything up mid-session. A tracking bar appears across the app while the session runs.

Configure the target entity, the saved keys, the accuracy and the session limits in the widget action — see Location tracking. For what the session looks like on the phone, see Live location tracking.

Stop live location tracking

Section titled Stop live location tracking

Ends the tracking session currently running in the app. It has no configuration of its own — the session already knows where it writes.

A session can also be stopped from the app’s tracking bar or tracking page, so a stop action on the dashboard is a convenience rather than a requirement.

Captures the current phone screen. Returns the image as a base64 data URL.

Configure the processImage function to handle the result — for example, store the screenshot as an entity attribute.