-
Notifications
You must be signed in to change notification settings - Fork 412
feat: read/unread status #1376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: read/unread status #1376
Changes from 9 commits
84ce9ad
f1b598f
39183e0
629c142
05b460e
13130ae
f465b0a
619a2e8
f39a87f
be82275
5286a03
e96aa08
c1a4910
442f9d3
a2a18a0
f693a7d
1187c9a
910905f
1efc3d2
2d8c80f
220a082
8f53bbc
b097f62
2a432d6
ed951e7
23a99d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ Links to sections on this page. Some sections are platform specific and are only | |
Change allowed notification types sent by dapp | ||
- [Fetching available notification types](#fetching-available-notification-types): | ||
Get latest notification types | ||
- [Updating messages read state](#updating-messages-read-state): | ||
Marking messages as read or unread across all devices | ||
- [Unsubscribe from a dapp](#unsubscribe-from-a-dapp): | ||
Opt-out from receiving notifications from a dapp | ||
- [Account logout](#account-logout): | ||
|
@@ -45,6 +47,9 @@ section are: | |
|
||
To check the full list of platform specific instructions for your preferred platform, go to [Extra (Platform Specific)](#extra-platform-specific) and select your platform. | ||
|
||
|
||
|
||
|
||
chris13524 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Initialization | ||
|
||
<CloudBanner /> | ||
|
@@ -553,6 +558,50 @@ const notificationTypes = notifyClient.getActiveSubscriptions({ account }).filte | |
</PlatformTabItem> | ||
</PlatformTabs> | ||
|
||
|
||
## Updating messages read state | ||
|
||
Updating a messages read state allows the user to know that they already looked at and seen the message. The state of being read is also synced across all devices where the user can see the notification. | ||
|
||
This method could be used in several ways in your UI, for example the user may click a button to mark the notification as read. Or you may automatically mark the notification is read when the notification is within the viewport. How you choose implement this is up to you. | ||
|
||
<PlatformTabs activeOptions={["ios","android", "react-native"]}> | ||
<PlatformTabItem value="ios"> | ||
</PlatformTabItem> | ||
<PlatformTabItem value="android"> | ||
|
||
|
||
```kotlin | ||
val topic: String = // active subscription topic | ||
val notificationIds: List<String> = // List of notification ids to mark as read | ||
val read: Boolean = // Read state to set the notifications to | ||
|
||
val params = Notify.Params.UpdateNotificationsReadState(topic, notificationIds, read) | ||
|
||
NotifyClient.updateNotificationsReadState( | ||
params, | ||
onSuccess = { | ||
// callback for when the change notifications read state request was successful | ||
}, | ||
onError = { error -> | ||
// callback for when the change notifications read state request has failed | ||
} | ||
) | ||
} | ||
``` | ||
|
||
</PlatformTabItem> | ||
<PlatformTabItem value="react-native"> | ||
```typescript | ||
notifyClient.updateNotificationsReadState({ | ||
topic: string, | ||
notificationIds: ["notification-id1", "notification-id2"], | ||
chris13524 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
read: true | ||
}) | ||
``` | ||
</PlatformTabItem> | ||
</PlatformTabs> | ||
|
||
## Unsubscribe from a dapp | ||
|
||
To opt-out of receiving notifications from a dap, a user can decide to unsubscribe from dapp. | ||
|
@@ -765,6 +814,10 @@ val walletDelegate = object : NotifyClient.Delegate { | |
override fun onError(error: Notify.Model.Error) { | ||
// Triggered when there's an error inside the SDK | ||
} | ||
|
||
override fun onNotifyNotificationsChanged(notifyNotificationsChanged: Notify.Event.NotificationsChanged) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing JS version of this, but I think we should de-scope notifications changed events: https://walletconnect.slack.com/archives/C044SKFKELR/p1710787967715679 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like we should remove this: WalletConnect/walletconnect-specs#191 (comment) |
||
// Triggered when a state was changed in the notifications | ||
} | ||
} | ||
|
||
NotifyClient.setDelegate(walletDelegate) | ||
|
Uh oh!
There was an error while loading. Please reload this page.