Skip to content

Commit

Permalink
Unsubscribe Push (#100)
Browse files Browse the repository at this point in the history
* add api client with grpc kotlin

* add unsubscribe ability

* update docs
  • Loading branch information
nplasterer authored Aug 3, 2023
1 parent 33d9d2a commit cc04c43
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/src/main/java/org/xmtp/android/library/push/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ This example branch can serve as the basis for what you might want to provide fo
```kotlin
XMTPPush(context, "10.0.2.2:8080").subscribe(conversations.map { it.topic })
```
```kotlin
XMTPPush(context, "10.0.2.2:8080").unsubscribe(conversations.map { it.topic })
```
11 changes: 11 additions & 0 deletions library/src/main/java/org/xmtp/android/library/push/XMTPPush.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ class XMTPPush() {
client.subscribe(request)
}

fun unsubscribe(topics: List<String>) {
if (pushServer == "") {
throw XMTPException("No push server")
}
val request = Service.UnsubscribeRequest.newBuilder().also { request ->
request.installationId = installationId
request.addAllTopics(topics)
}.build()
client.unsubscribe(request)
}

val client: NotificationsGrpc.NotificationsFutureStub
get() {
val protocolClient: ManagedChannel =
Expand Down

0 comments on commit cc04c43

Please sign in to comment.