Closed DasJhaman closed 3 years ago
I would suspect you have deliberately ignored ten lines asking to add logs?
But anyway, here's the problematic line:
ChatCallbackListener<Channel>() {
it!!.messages?.getLastMessages(1, ChatCallbackListener<List<Message>>() {
messages
is null so it doesn't do anything. You should wait for complete channel synchronization first. See docs.
How do I call channel synchronization, could you please share the documentation link.
it.getUnconsumedMessagesCount(object : CallbackListener<Long>() {
override fun onSuccess(p0: Long?) {
if (p0 != null){
binding.tvUnReadMessagesCount.visibility = View.VISIBLE
binding.tvUnReadMessagesCount.text = ""+ p0
}
}
})
why unConsumed method not working as it giving me null.
@DasJhaman because you did not mark any messages as read, so by default they are all unread.
I want to get the unread message count and want to display it on each chat room, which method is allowing so?
@berkus by default they are all unread than it should return me the count, or any other method to get an unread count?
If it returns null you should query Channel.getMessagesCount()
.
Not an ideal usability but currently SDK is very explicit about the steps you need to do.
as per document getMessageCount()
return me the total message count in that chat thread, but I need only unread message count, how can I get this.
If all messages are unread, then you need the total message count - it equals unread message count (which equals ALL messages in the channel).
If suppose i don't have all messages unread, only 2 are unread then?
Well, how many messages total do you have in the channel?
More than 50
On Thu, Feb 11, 2021, 8:39 PM Berkus Decker notifications@github.com wrote:
Well, how many messages total do you have in the channel?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/twilio/twilio-chat-demo-android/issues/159#issuecomment-777585417, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6J5M3JFOMBIRR4JJIJQ73S6P233ANCNFSM4XNLZMYA .
But getMessagesCount() returns only 2??
No it's returning me, total count.
So it's correct, you have total count
unread messages, what do you complain about?
If you had only 2 unread messages this would mean you marked some messages as read, but you didn't, so they are still unread. All as designed.
You should mark at least one message as read with this method and then getUnconsumedMessagesCount
will return actual unread message count.
By the way, its documented in detail in this method description, so make sure to read the documentation.
` private fun getLastMessageDate(chatThreadsitems: MutableList<Data>) {
chatThreadsitems.forEachIndexed { index, any ->
Log.e("text","looping $ "+index)
hayiChatClient.chatClient!!.channels!!.getChannel(
any.remoteChannelId,
ChatCallbackListener<Channel>() {
GlobalScope.launch {
it.waitForSynchronization()
any.channel = it
any.lastUpdatedAt = CommonMethods.getMileSeconds(it.lastMessageDate)
}
})
}
ProgressDialogBox.dismissDialog()
sortAndSetItems(chatThreadsitems)
}`
@berkus @Gray-Wind some time my above method working fine and sometimes getting channel null, why this happening so, what is the best solution to deal with this. Thoug i am syncing the channel as well
It could be null because it's not found. Callback listener has onError() method - is it called?
No, I am not using the onError method, I know it's null, why it's not found? Sometimes it's running perfectly some time making this issue? How can I execute this efficiency?
What do the logs say when it's null?
E/text: looping $ 0 I/TWC: | Chat IPM | client [api] get channels D/TWC: | SDK EntityCache | Returning Java object from cache I/TWC: | Chat IPM | channels: [api] get channel 446_447_uniqueName D/TWC: | Chat IPM | [BFGDg] got channel from cache 446_447_uniqueName | Chat IPM | channels: got from cache 446_447_uniqueName E/text: looping $ 1 D/TWC: | SDK EntityCache | Returning Java object from cache I/TWC: | Chat IPM | client [api] get channels D/TWC: | SDK EntityCache | Returning Java object from cache I/TWC: | Chat IPM | channels: [api] get channel 437_447_uniqueName D/TWC: | Chat IPM | [1G2Ro] got channel from cache 437_447_uniqueName
as per the loop, it's working perfectly but what is happening here my loop getting execute after that I am getting these logs. @berkus
Can I see the logs please?
D/SurfaceExt: ENABLE_WHITE_LIST: false,isInWhiteList: false
D/Surface: lockCanvas
I/zygote64: Do partial code cache collection, code=1007KB, data=608KB
I/zygote64: After code cache collection, code=1007KB, data=608KB
Increasing code cache capacity to 3MB
V/FA: Inactivity, disconnecting from the service
E/text: channel looping $ Fri Feb 19 16:52:34 GMT+05:00 2021
D/TWC: | SDK Channel(native) | getSynchronizationStatus for channel sid|CHdea6bba7292e46e8be3350549f4c6159|
D/TWC: | SDK Channel(native) | getSynchronizationStatus for channel sid|CHdea6bba7292e46e8be3350549f4c6159|
E/text: channel looping $ Thu Feb 18 23:07:08 GMT+05:00 2021
D/TWC: | SDK Channel(native) | getSynchronizationStatus for channel sid|CHa953f9b77137464eadbfe1fd49c9915a|
| SDK Channel(native) | getSynchronizationStatus for channel sid|CHa953f9b77137464eadbfe1fd49c9915a|
I/WebSocketWrapper: [1] onBinaryMessage: 96
I/WebSocketWrapper: [1] cancelTimer
[1] startTimer: 43000
D/TWC: 3 | Twilsock Client | onMessageReceived, method = 2, id = TM8e64ee72138f4031a3f5d099a7f152a4
D/TWC: 3 | Twilsock Client | processPingMessage in state Connected , TM8e64ee72138f4031a3f5d099a7f152a4
3 | Twilsock Client | sendReplyImpl in state Connected
3 | Twilsock Client | sendReply: 200, ok, TM8e64ee72138f4031a3f5d099a7f152a4,
V/StudioTransport: Handling agent command 1200 for pid: 6453.
V/StudioTransport: Handling agent command 1200 for pid: 6453.
I/zygote64: Background concurrent copying GC freed 115352(5MB) AllocSpace objects, 0(0B) LOS objects, 36% free, 10MB/16MB, paused 281us total 160.787ms
V/StudioTransport: Handling agent command 1200 for pid: 6453.
V/StudioTransport: Handling agent command 1200 for pid: 6453.
V/StudioTransport: Handling agent command 1200 for pid: 6453.
V/StudioTransport: Handling agent command 1200 for pid: 6453.
V/FA: Recording user engagement, ms: 30712
V/FA: Connecting to remote service
E/: nFreeSize: 1394151424
V/FA: Activity paused, time: 231479982
V/StudioTransport: Handling agent command 1200 for pid: 6453.
V/FA: Connection attempt already in progress
D/FA: Connected to remote service
Proper trace level log should have at least 500 times more lines.
You can enable detailed logging and submit the resulting log file through help.twilio.com support (as it will contain some details of your account as well).
Here are the details on enabling the log level.
@berkus link of submit log redirecting me to here https://www.twilio.com/
My bad, should be https://support.twilio.com/
Is there any way to set twilio connection time out, if my wifi is off and i am going to connect twilio connection, webscoket is not calling onError method quickly, websocket holding the request more than 5 minutes. Is there any workaround? @berkus
Yes, there is a way. You need to use setCommandTimeout in options for a client creation.
Thanks, @Gray-Wind, can you guide me why I am getting channel status UNKNOWN for the invited user in channel descriptor, and not getting channel if i use getChannel method from remoteChannelSid. Please guide me on how to get the invited status of the channel.
Getting following error in log:
D/TWC: | Http HttpResponse.ctor | payload '{"code":54007,"status":403,"message":"Access forbidden for identity"}' I/TWC: 172 | Sync TSCollectionOpenActivity | response status 403 body "{"code":54007,"status":403,"message":"Access forbidden for identity"}" (69 bytes) W/TWC: 171 | Sync List | request 37 error code 54007: Access forbidden for identity | Chat IPM | [yGAiy] messages: error 54007 Access forbidden for identity
No logs, closing.
If you still have this problem, please open a new ticket with proper full log.
Description
Code (optional)
Using the following code for getting last message:
Expected Behavior
Get Last message of each channel
Actual Behavior
Not getting any of message loop getting execute
[What actually happens]
Reproduces how Often
[What percentage of the time does it reproduce?]
Logs
Please collect logs as described here. Full unedited logs help reproduce and fix issues faster.
Or attach it as a file.
Logs
Yes, if you didn't collect the logs as described above, please collect the logs. Do not file the issue if you don't have enough information, this means having some logs, too.
Logs
Logs
Logs
Logs
Logs
Logs
Yes, seriously. Please send logs!
Versions
All relevant version information for issue, fill in below:
Chat Android SDK
Which SDK version did you use? [eg. 2.0.8]
Android API
On which Android API version or versions does it happen? [eg. 18]
Android Device
Vivo
Device or devices on which the problem happens [eg. Nexus 5]