Skip to content

Commit 0dcecd2

Browse files
committed
Add multiple notification examples
1 parent e7a2e0a commit 0dcecd2

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

snaps/reference/snaps-api.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ await snap.request({
864864
## `snap_notify`
865865

866866
Displays a [notification](../features/notifications.md) in MetaMask or natively in the OS.
867-
Snaps can trigger a short notification text for actionable or time sensitive information.
867+
Snaps can trigger a short (up to 80 characters) notification message for actionable or time sensitive information.
868868
`inApp` notifications can also include an optional [expanded view](../features/notifications.md#expanded-view).
869869
The expanded view has a title, content, and optional footer link shown when a user clicks on the notification.
870870

@@ -887,7 +887,23 @@ Expanded view can only be used with notifications of type `inApp`.
887887
Expanded view must have at least a `title` and `content`.
888888
:::
889889

890-
#### Example
890+
#### Examples
891+
892+
<Tabs>
893+
<TabItem value="In-app">
894+
895+
```javascript title="index.js"
896+
await snap.request({
897+
method: "snap_notify",
898+
params: {
899+
type: "inApp",
900+
message: "Hello, world!",
901+
},
902+
})
903+
```
904+
905+
</TabItem>
906+
<TabItem value="In-app with Expanded View">
891907

892908
```javascript title="index.js"
893909
await snap.request({
@@ -904,12 +920,28 @@ await snap.request({
904920
),
905921
footerLink: {
906922
href: "https://snaps.metamask.io",
907-
text: "Find more Snaps"
908-
}
923+
text: "Find more Snaps",
924+
},
909925
},
910926
})
911927
```
912928

929+
</TabItem>
930+
<TabItem value="Native">
931+
932+
```javascript title="index.js"
933+
await snap.request({
934+
method: "snap_notify",
935+
params: {
936+
type: "native",
937+
message: "Hello, world!",
938+
},
939+
})
940+
```
941+
942+
</TabItem>
943+
</Tabs>
944+
913945
## Interactive UI methods
914946

915947
The following methods are used in [interactive UI](../features/custom-ui/interactive-ui.md).

0 commit comments

Comments
 (0)