Does anyone know
- How to correctly initialize the Notification API WebSocket connection in a Kotlin Android environment using the official Genesys Cloud SDK?
- I am attempting to subscribe to
routing:conversation:updatedevents to update my custom UI in real-time without polling. - My current implementation uses
PlatformClient.getNotificationClient().subscribe()but I am encountering intermittent403 Forbiddenerrors during the handshake phase. - The error payload returns
{ "error": "invalid_grant", "error_description": "The access token provided is invalid or expired" }even though I am using a valid OAuth2 token retrieved viaPlatformClient.login(). - I suspect the issue lies in how the subscription request JSON is structured for the
POST /api/v2/notifications/subscribeendpoint before the WebSocket upgrade. - Here is the relevant Kotlin snippet handling the subscription:
val subscription = NotificationSubscriptionBuilder()
.setEventTypes(listOf("routing:conversation:updated"))
.build()
platformClient.notifications.subscribe(subscription, object : SubscriptionCallback {
override fun onSubscribe(success: Boolean) {
// Logic here
}
})
- The WebSocket connection seems to drop immediately after the initial
CONNECTframe is sent. - Is there a specific header requirement for Android-based WebSocket clients when interacting with the Genesys Cloud Notification API?
- I have verified that the token has the necessary
notification:readscope.