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.
Configure a mobile action
Section titled “Configure a mobile action”- Go to Dashboard groups in the left main menu.
- Open the target dashboard group.
- Click the dashboard you want to modify.
- In the dashboard details panel, click Open dashboard.
- Click the Edit (pencil) button in the bottom-right corner to enter edit mode.
- Click the Edit (pencil) icon on the target widget to open its settings.
- Navigate to the Actions tab.
- Click + to add a new action.
- In the Type drop-down, select Mobile action.
- In the Mobile action type drop-down, select the action type you want.
- Configure the JavaScript function with your processing logic. Use the help buttons for function definitions and examples.
Action types
Section titled “Action types”Take picture from gallery
Section titled “Take picture from gallery”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.
Take photo
Section titled “Take photo”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.
Open map directions
Section titled “Open map directions”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.
Open map location
Section titled “Open map 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.
Scan QR code
Section titled “Scan QR code”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.
Make phone call
Section titled “Make phone call”Takes a phone number and opens the appropriate app to initiate a call.
Configure the getPhoneNumber function to extract the number from entity attributes.
Get phone location
Section titled “Get phone location”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.
Take screenshot
Section titled “Take screenshot”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.