sud.showToast
Displays a toast message. Call sud.hideToast to close it early.
javascript
sud.showToast(object);Parameters
| Property | Type | Required | Description |
|---|---|---|---|
| title | string | Yes | Text to display |
| icon | string | No | Icon type; see the values below and set explicitly |
| image | string | No | Local file path of a custom icon; takes precedence over icon |
| duration | number | No | Display duration in milliseconds; explicitly set a positive value |
| mask | boolean | No | Whether to display a transparent overlay that blocks touch events from reaching the content beneath it; set explicitly |
| success | function | No | Called on success; no additional result fields |
| fail | function | No | Called on failure; see the fields below |
| complete | function | No | Called after success or failure, with no arguments |
Valid icon Values
| Value | Description |
|---|---|
| success | Success icon |
| error | Error icon |
| loading | Loading icon |
| none | No icon |
Failure Callback Parameters
| Property | Type | Description |
|---|---|---|
| errCode | number | Error code |
| errMsg | string | Error description |
Usage Notes
Confirm that the target app supports this UI feature before using it. Keep the message brief and explicitly set the icon, duration, and overlay. The success callback reports a successful display request, not that the toast has closed.
Example
javascript
sud.showToast({
title: 'Saved',
icon: 'success',
duration: 2000,
mask: false,
fail(error) {
console.error('Failed to show toast', error.errCode, error.errMsg);
}
});