2020-06-04 13:28:44 +00:00
|
|
|
# Notifications (default)
|
|
|
|
|
2021-09-27 22:23:57 +00:00
|
|
|
The default version of the `notify` module for displaying notifications in a bar at the top of the screen
|
2020-06-04 13:28:44 +00:00
|
|
|
|
2021-09-27 22:23:57 +00:00
|
|
|
This module is installed by default by client applications such as Gadgetbridge.
|
2020-06-04 13:28:44 +00:00
|
|
|
|
2021-09-21 09:50:04 +00:00
|
|
|
**Note:** There are other implementations of this library available such
|
|
|
|
as `notifyfs` (Fullscreen Notifications). These can be used in the exact
|
|
|
|
same way from code, but they look different to the user.
|
|
|
|
|
2020-06-04 13:28:44 +00:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
```JS
|
|
|
|
options = {
|
2021-03-20 18:18:39 +00:00
|
|
|
on : bool, // turn screen on, default true (But not if Quiet Mode is enabled)
|
2021-03-04 10:30:23 +00:00
|
|
|
size : int, // height of notification, default is fit to height (80 max)
|
2020-06-04 13:28:44 +00:00
|
|
|
title : string, // optional title
|
2020-07-07 18:45:03 +00:00
|
|
|
id // optional notification ID, used with hide()
|
2020-06-04 13:28:44 +00:00
|
|
|
src : string, // optional source name
|
|
|
|
body : string, // optional body text
|
|
|
|
icon : string, // optional icon (image string)
|
2021-03-04 10:30:23 +00:00
|
|
|
render function(area) {} // function callback to render in area{x,y,w,h}
|
2020-06-04 13:28:44 +00:00
|
|
|
};
|
|
|
|
// eg... show notification
|
|
|
|
require("notify").show({title:"Test", body:"Hello"});
|
2020-06-04 14:43:20 +00:00
|
|
|
// or display lots of text, with a phone icon
|
|
|
|
require("notify").show({
|
|
|
|
title:"Hello",
|
|
|
|
src:"Test",
|
|
|
|
body:"This is a really really really long bit of text that has to be wrapped",
|
|
|
|
icon:require("heatshrink").decompress(atob("jEYxH+ACcejwUUAAYWVjESCqoABCqoYNCpQXLCxgXJQowtTA4ZbSZiwW/C4gWWjAXVZwIuVWhxFIC6z6OLpIXSCywXYDAIWVAAYXTA=="))
|
|
|
|
});
|
2020-06-04 13:28:44 +00:00
|
|
|
// remove it (can also be removed by tapping)
|
|
|
|
require("notify").hide();
|
2020-07-07 18:45:03 +00:00
|
|
|
|
|
|
|
// Use ID to only hide a specific notification if it is still visible
|
|
|
|
require("notify").show({id:1, title:"Test", body:"Some Alert"});
|
|
|
|
require("notify").show({id:"msg", title:"Message", body:"Incoming Message"}); // replaces Test Alert
|
|
|
|
require("notify").hide({id:1}); // does nothing, because the Test Alert was already replaced
|
|
|
|
require("notify").hide({id:"msg"}); // hides Message
|
|
|
|
require("notify").hide(); // hides current notification, whatever it was
|
2020-06-04 13:28:44 +00:00
|
|
|
```
|