Text metric: On Tap

This handler called when user taps (clicks) on the tile.

Note: This handler is executed each time in CLEAN mode. This means, that previous call state will be cleaned up (any declared variables and functions in previous call will be purged in subsequent call)!
To pass data between calls and handlers use event.data.

In this handler you can use the following:

app.publish(topic, payload, retained, qos);

Publish payload (String) to topic (String) with specified retained flag (Boolean) and qos (Integer). Example:

app.publish('messages/alert', 'HOT', false, 0);


Open specified uri (String) in an external app. uri examples:
- http://www.example.com/page.html
- tel:123
- content://contacts/people/



(Any type) Custom runtime user data, bound to this particular metric. You can get/set any data, which you need to be preserved between calls.
The data shared between On Receive, On Display, On Tap handlers. So you can set data in On Receive and use this data later in On Display.

Warning: never pass functions through event.data!
The data NOT preserved between app launches. Usually, because the data is not assigned by default, you want to start your handler’s code with check if data assigned, and then use the data:

In On Receive handler:

if (!event.data) {
    event.data = {};
event.data['some flag'] = (event.payload == 'something' ? true : false);

In On Display or in On Tap handler:

if (event.data['some flag']) {
    // do something
} else {
    // do something other


(Boolean) False by default. If True, default tap event behaviour will be disabled.

// prevent default event handler call and publish message
event.preventDefault = true;
if (event.data['some flag']) {
    app.publish('messages/alert', JSON.stringify(event.data), false, 0);