
Hello! I tried to use Realtime Subscription to receive User Document's updates, but in examples at the Appwrite Docs don't found correctly example to my Java. Briefly, I need to receive when User Document's updates and check "chats" (List<String>) parameter. If this changed, make a notification. Is it possible to receive this directly in Realtime Object? How to subscribe Realtime Channel/Channels?

Yes this is possible. What do you have now and what's wrong?

i don't know how to use RealtimeResponseListener (syntacsys)

and what usually means Object in that case

What's your code?

something like this ```String[] channels = new String[0]; realtime.subscribe(channels, new RealtimeResponseEvent<>((result21, error21) -> { if (error21 != null) { error21.printStackTrace(); return; }
Log.d("Appwrite", result21.toString());
}));```

So you'll need to specify the channels, but besides that, what's wrong?

when i typing result21 as object, it means <lambda parameter>? i don't understand it in that case

So you're getting a build error?

this also, error21.printStackTrace() and result21.toString()

Would you please share the exact error?

But when I do other functions, I receive io.appwrite.models, in example io.appwrite.models.Account and i getting parameters from this. Is this analogue like io.appwrite.models as result21?

cannot resolve method in both cases

Possibly...please share the full exact error

I solved this, but I had some questions. Is the realtime subscription returns payload and what can I do with that? What kind of data I can receive from payload?

Payload would match the event. For example, if you're subscribed to documents, the payload will be a document

I can cast it to Appwrite Document if subscribe in Document Updates? If I subscribe to Appwrite Collection Changes?

i rewrited code as ```RealtimeSubscription realtimeSubscription = realtime.subscribe(channelsArray, new RealtimeResponseEvent<>((events, channels, eventTimestamp, eventPayload) -> {
}));``` and receiving Multiple non-overriding abstract methods found in interface java.util.Collection error.

Yes, you can't change the parameters

Realtime response event is a generic...is that what's it's called in Java? You can pass a type to indicate what the type of the payload is. See https://github.com/appwrite/sdk-for-android/blob/c5974e005753b963bfc18d09c7f56bea97e2173c/library/src/main/java/io/appwrite/models/RealtimeModels.kt#L23
Recommended threads
- WebSocket connection failed - Realtime g...
I am using appwrite cloud + angular (appwrite 21.2.1). On Chrome, when I have a realtime subscribtion and I reload the page or navigate to another page, realtim...
- 1.7.2 Node-appwrite createDocuments from...
Am I correct in my testing that functions with document creation event, wont trigger on calling createDocuments from within a function.
- Flutter OAuth2 Google Login – Redirect I...
i tried implementing OAuth2 Google Login in my app, and it works fine for the most part, the problem am facing is when i chose a google account to sign in/up wi...
