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
- Subscription Problem
I'm making an app in RN with Expo and Appwrite and there's a functionality which allows the user to create a task/test (i'll be reffering to them collectively a...
- Cant get realtime working
Hey I nned some help with realtime a gain. I was using client.subscribe(...), and i found out that its depricated then i believe realtime.subscribe(...) is the ...
- Error with realtime channels
I'm performing a subscription to realtime channels, and after a few seconds I get an exception with this error: {\"type\":\"error\",\"data\":{\"code\":1008,\"me...