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
- Deep Linking & Password reset
I am using react native with expo. I want to implement deep link with the url recived via email. So when clicked the link it opens my app. I havent ever used de...
- custom domain with CloudFlare
Hi all, it seems that CloudFlare has blocked cross-domain CNAME link which made my app hostname which is in CloudFlare, unable to create a CNAME pointing to clo...
- My organization's project is blocked
My organization's project is blocked so unblocked my organization then I will this