Skip to content

Commit cc04c43

Browse files
authored
Unsubscribe Push (#100)
* add api client with grpc kotlin * add unsubscribe ability * update docs
1 parent 33d9d2a commit cc04c43

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

library/src/main/java/org/xmtp/android/library/push/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,7 @@ This example branch can serve as the basis for what you might want to provide fo
7979
```kotlin
8080
XMTPPush(context, "10.0.2.2:8080").subscribe(conversations.map { it.topic })
8181
```
82+
83+
```kotlin
84+
XMTPPush(context, "10.0.2.2:8080").unsubscribe(conversations.map { it.topic })
85+
```

library/src/main/java/org/xmtp/android/library/push/XMTPPush.kt

+11
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ class XMTPPush() {
5151
client.subscribe(request)
5252
}
5353

54+
fun unsubscribe(topics: List<String>) {
55+
if (pushServer == "") {
56+
throw XMTPException("No push server")
57+
}
58+
val request = Service.UnsubscribeRequest.newBuilder().also { request ->
59+
request.installationId = installationId
60+
request.addAllTopics(topics)
61+
}.build()
62+
client.unsubscribe(request)
63+
}
64+
5465
val client: NotificationsGrpc.NotificationsFutureStub
5566
get() {
5667
val protocolClient: ManagedChannel =

0 commit comments

Comments
 (0)