API Reference - HMI.notificationActivity
This API allows to interact with the HMI notificationActivity UI element element.
Input Parameter | |||||
---|---|---|---|---|---|
Param name | Description | Type | Unit/Values | Example | Required |
action | Action to perform. |
Enum of strings |
- create
- close
|
create
|
true |
notificationId | ID of the notification Activity UI element you want to close. This ID is return when creating the element. It’s the only parameter required along with action if |
int |
|
42
|
true |
title | Name of the notification. If |
string |
|
Car maintenance reminder
|
true |
text | Text of the notification. If |
string |
|
Your appointment with your favorite garage has been confirmed.
|
true |
timestamp | Notification timestamp. If |
string |
|
573041587
|
true |
button1Icon | File, data or URI of the button icon. If |
string |
|
file://assets/icons/play.png
|
true |
button2Icon | File, data or URI of the button icon. If |
string |
|
data:image/png;base64,...
|
false |
button3Icon | File, data or URI of the button icon. If |
string |
|
data:image/png;base64,...
|
false |
userData | Custom parameters of any types available when notification activity is triggered. |
Object |
|
{"custom"=>"payload", "myObj"=>{"a"=>"hello", "b"=>[1, 2, 3]}}
|
false |
Output Data | ||||
---|---|---|---|---|
Data name | Description | Type | Unit/Values | Example |
notificationId | ID of the notificationActivity UI element you just set-up. This ID is also returned in Susbscribe. |
int |
|
42
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
webportal.set(
/* api name */
"HMI.notificationActivity",
/* parameters */
{
"action": "create",
"notificationId": 42,
"title": "Car maintenance reminder",
"text": "Your appointment with your favorite garage has been confirmed.",
"timestamp": "573041587",
"button1Icon": "file://assets/icons/play.png",
"button2Icon": "data:image/png;base64,...",
"button3Icon": "data:image/png;base64,...",
"userData": "{"custom"=>"payload", "myObj"=>{"a"=>"hello", "b"=>[1, 2, 3]}}"
}
)
/* callback for `REPLY` messages */
.then((message) => {
if (message.status === 200) {
/* handle `REPLY` success */
}
else { /* handle `REPLY` error */ }
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
"id": "7372c16f-5f2f-42c9-84a7-5490e35f1be0",
"type": "SET",
"api": "HMI.notificationActivity",
"params": {
"action": "create",
"notificationId": 42,
"title": "Car maintenance reminder",
"text": "Your appointment with your favorite garage has been confirmed.",
"timestamp": "573041587",
"button1Icon": "file://assets/icons/play.png",
"button2Icon": "data:image/png;base64,...",
"button3Icon": "data:image/png;base64,...",
"userData": "{"custom"=>"payload", "myObj"=>{"a"=>"hello", "b"=>[1, 2, 3]}}"
}
}
1
2
3
4
5
6
7
8
9
10
// --- format of the `REPLY` message ---
{
"id": "7372c16f-5f2f-42c9-84a7-5490e35f1be0",
"type": "REPLY",
"api": "HMI.notificationActivity",
"status": 200,
"statusText": "OK",
"data": 42
}
false
This API allows to interact with the HMI notificationActivity UI element element.
Input Parameter | |||||
---|---|---|---|---|---|
Param name | Description | Type | Unit/Values | Example | Required |
notificationId | ID of the notificationActivity UI element you want to subscribe to. If not provided will subscribe to every notifications. |
int |
|
42
|
false |
Output Data | ||||
---|---|---|---|---|
Data name | Description | Type | Unit/Values | Example |
notificationId | ID of the notificationActivity UI element being triggered. This ID is also returned in Set. |
int |
|
42
|
event | Notification event related to the triggering of this notificationActivity UI element. |
Enum of strings |
- button1
- button2
- button3
- content
|
button1
|
userData | Custom parameters provided in Set. |
Object |
|
{"custom"=>"payload", "myObj"=>{"a"=>"hello", "b"=>[1, 2, 3]}}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
webportal.subscribe(
/* api name */
"HMI.notificationActivity",
/* parameters */
42,
/* callback for `NOTIFY` messages */
async (notifyMessage) => {
if (notifyMessage.status === 200) {
/* handle `NOTIFY` response */
}
else { /* handle `NOTIFY` error */ }
}
)
/* callback for `REPLY` messages */
.then((message) => {
if (message.status === 200) {
/* handle `REPLY` success */
}
else { /* handle `REPLY` error */ }
})
1
2
3
4
5
6
{
"id": "7372c16f-5f2f-42c9-84a7-5490e35f1be0",
"type": "SUBSCRIBE",
"api": "HMI.notificationActivity",
"params": 42
}
1
2
3
4
5
6
7
8
9
10
11
// --- format of the `REPLY` message ---
// type: acknowledge the status of the subscription
// reception: only once after the subscription request
// contains outputed data: no
{
"id": "7372c16f-5f2f-42c9-84a7-5490e35f1be0",
"type": "REPLY",
"status": 200,
"statusText": "OK"
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// --- format of the `NOTIFY` message ---
// type: event message about the subscription
// reception: each time the conditions of the subscription are met
// contains outputed data: yes
{
"id": "7372c16f-5f2f-42c9-84a7-5490e35f1be0",
"type": "NOTIFY",
"api": "HMI.notificationActivity",
"status": 200,
"statusText": "OK",
"data": {
"notificationId": 42,
"event": "button1",
"userData": "{"custom"=>"payload", "myObj"=>{"a"=>"hello", "b"=>[1, 2, 3]}}"
}
}