WLWebview Kiosk
SettingsMQTTTopics

Command

Subscribe to control commands (actions)

1. Settings

1.1. Topic Name

All global variables are supported. For example,

wk/${USERNAME}/${APP_INSTANCE_ID}/command

Default:

wk/command

1.2. Quality of Service (QoS)

Quality of Service (QoS) ensures different message delivery guarantees in case of connection failures.

Default: At Most Once (0)

1.3. Retain Handling

Control whether Webview Kiosk should receive existing retained messages when subscribing.

Default: Do Not Send (2)

1.4. Retain as Published

Controls whether retained messages from the broker keep their original retained flag when delivered to the subscriber.

Default: false

2. Payloads

In addition to the Shared Subscribe Payload Properties, the following properties exists for all commands:

PropertyTypeDescription
commandstringThe command to execute, e.g. clear_history.
interactboolean (optional)

Whether a user interaction should be triggered.

For example, this will restore brightness if Web Lifecycle → Dim Screen on Inactivity (seconds) is configured.

Default: true

wakeScreenboolean (optional)

Whether to wake the screen if it is turned off.

This requires Settings → MQTT → Use Foreground Service.

It is highly recommended that you disable battery optimisation for Webview Kiosk, which will help keep its foreground service alive.

For more details, visit

Default: false

2.1. Go Back

Navigates one page back in history.

Example payload:

{
  "command": "go_back"
}

2.2. Go Forward

Navigates one page forward in history.

Example payload:

{
  "command": "go_forward"
}

2.3. Go Home

Navigates to your configured home page.

Example payload:

{
  "command": "go_home"
}

2.4. Refresh

Refresh the current webview page.

Example payload:

{
  "command": "refresh"
}

2.5. Go to URL

Navigates to a specific URL.

Example Payload:

{
  "command": "go_to_url",
  "data": {
    "url": "https://webviewkiosk.nktnet.uk"
  }
}

Perform a query search using the selected search engine. This is the same as using Webview Kiosk's address bar.

Example Payload:

{
  "command": "search",
  "data": {
    "query": "How to Train Your Dragon"
  }
}

2.7. Clear History

Removes the navigation history, leaving the current URL as the only entry in the stack.

Example Payload:

{
  "command": "clear_history"
}

2.8. Toast

Shows a short toast message.

If the message is empty or only contains white space, no toast will be shown. This is still helpful if you need a dummy command to:

  • trigger a user interaction with the interact property
  • turn the screen on with the wakeScreen property

Example Payload:

{
  "command": "toast",
  "data": {
    "message": "Welcome!"
  }
}

2.9. Lock

Start lock task mode (or screen pinning) depending on whether Webview Kiosk has device owner permissions.

Please note that for screen pinning, the user will be prompted to confirm the action, which needs to be done on the device.

If possible, we recommend to always enable lock task packages for Webview Kiosk - more details in the security section.

Example Payload:

{
  "command": "lock"
}

2.10. Unlock

Stop lock task mode (or screen pinning) depending on whether Webview Kiosk has device owner permissions.

Example Payload:

{
  "command": "unlock"
}

2.11. Reconnect

Disconnect, then reconnect and resubscribe to all MQTT topics.

This is helpful if you have updated any MQTT-related settings, which requires a reconnection to apply.

Example Payload:

{
  "command": "reconnect"
}

2.12. Lock Device

Turns the device screen off. Note that this will also stop the MQTT connection.

Example Payload:

{
  "command": "lock_device"
}

2.13. Page Up

Scrolls the contents of this WebView up by half the view size.

You can also specify absolute: true in the payload's data property to scroll fully up the page.

This command uses the Webview#pageDown API.

Example Payload:

{
  "command": "page_up"
}

2.14. Page Down

Scrolls the contents of this WebView down by half the page size.

You can also specify absolute: true in the payload's data property to scroll fully down the page.

This command uses the Webview#pageUp API.

Example Payload:

{
  "command": "page_down"
}

2.15. Notify

Shows a notification on the device.

The title comes from the most recent message, and the body will display the content text of the last 5 messages.

This feature requires:

  • Android POST_NOTIFICATIONS permission
  • Settings -> Device -> Allow Notifications

Additionally, when in kiosk/locked mode, the following are required:

  • Device owner or Dhizuku privileges
  • Settings -> Device -> Device Owner -> Home
  • Settings -> Device -> Device Owner -> Notifications

Your payload data value can have the following properties:

PropertyTypeDefaultDescription
contentTitlestring?MQTTThe title of the notification.
contentTextstringNotifyThe content body of the notification.
silentboolean?falseIf true, the notification will not make sound or vibration.
onGoingboolean?falseSee NotificationCompat.Builder#setOngoing(boolean).
prioritystring?DEFAULTNotification priority: MIN, LOW, DEFAULT, HIGH, or MAX.
timeoutlong?0Time in milliseconds before auto-dismiss (0 = no timeout).
autoCancelboolean?trueDismiss the notification when the user taps it.

Example payload:

{
  "command": "notify",
  "data": {
    "contentText": "Hello, World!"
  }
}

2.16. Launch Package

Open an application based on its package name, e.g. com.afwsamples.testdpc.

In Lock Task Mode, the same restrictions outlined in Web Browsing under Kiosk Control Panel Actions -> Apps applies.

Additionally, packages can only be launched when Webview Kiosk is in the foreground, unless direct Device Owner permission has been granted. Dhizuku is insufficient.

In the payload data, you can optionally specify the activityName. For example, this can be any of the following:

  • com.afwsamples.testdpc.PolicyManagementActivity
  • .PolicyManagementActivity
  • PolicyManagementActivity

Example Payload:

{
  "command": "launch_package",
  "data": {
    "packageName": "com.afwsamples.testdpc"
  }
}

2.17. Clear Cache

Clears webview cache. This is equivalent to Clear Cache Action.

Example Payload:

{
  "command": "clear_cache"
}

Last updated on

On this page