snap_notify
Description
Display a
notification in
MetaMask or natively in the OS. Snaps can trigger a short (up to 80
characters) notification message for actionable or time sensitive
information. inApp notifications can also include an optional
expanded view.
The expanded view has a title, content, and optional footer link shown when
a user clicks on the notification.
Parameters
An object containing the parameters for the snap_notify method.
Options
type
"native"The literal string "native" to indicate that this is a native OS
notification. We recommend using inApp instead, as native
notifications may be rate-limited by the operating system.
or
type
"inApp"The literal string "inApp" to indicate that this is an in-app notification displayed in the MetaMask UI.
or
type
"inApp"The literal string "inApp" to indicate that this is an in-app notification displayed in the MetaMask UI.
content
JSXElementThe custom UI content to display when the notification is expanded.
title
stringThe title of the expanded notification.
footerLink
objectAn optional link to display in the footer of the expanded notification.
href
stringThe URL to navigate to when the link is clicked.
text
stringThe link text to display.
Common properties
message
stringThe message to display in the notification.
Returns
This method does not return any data, so the result is always null.
Examples
Basic in app notification
- Manifest
- Usage
{
"initialPermissions": {
"snap_notify": {}
}
}
snap.request({
method: "snap_notify",
params: {
type: "inApp",
message: "This is an in-app notification",
},
});
Expandable in app notification
- Manifest
- Usage
{
"initialPermissions": {
"snap_notify": {}
}
}
snap.request({
method: "snap_notify",
params: {
type: "inApp",
message: "This is an in-app notification",
title: "Notification Title",
content: (
<Box>
<Text>This is the expanded content of the notification.</Text>
</Box>
),
footerLink: {
href: "https://example.com",
text: "Click here for more info",
},
},
});
Native notification
- Manifest
- Usage
{
"initialPermissions": {
"snap_notify": {}
}
}
snap.request({
method: "snap_notify",
params: {
type: "native",
message: "This is a native notification",
},
});