Closed lethanhclub closed 11 months ago
Could you please specify all required fields we are requesting in the template to issue? Which platform do you use while reproducing this issue? Can you reproduce it in the latest version of our sample? Please provide the full log from the device during the reproduction of this issue. We just checked it a few times on Android and iOS and can't reproduce it in the Chat sample from the master branch.
this bug happened on both iOS and android. You have to turn off wifi and LTE while the app is still in foreground, then you send a few messages to the offline device. Finally, you turn on wifi/LTE and wait for reconnecting. You can see offline messages lost sometimes.
can you please share the log from the device where you reproduce this issue? or please specify in more detail how can we reproduce it on our side. turning on/off the internet connection on our side doesn't lead to this issue
can you please share the log from the device where you reproduce this issue? or please specify in more detail how can we reproduce it on our side. turning on/off the internet connection on our side doesn't lead to this issue
I just updated my post with log.
Can you receive messages after successful reconnection? I mean messages sent after reconnection, not messages sent when a user was offline. To avoid the inconsistency of data you can request new messages via an API request. You can request the messages with the date_sent
more than received last message's dateSent
. You can use the next request for it:
Future<List<CubeMessage>> getMessagesByDate(int date, bool isLoadNew) async {
var params = GetMessagesParameters();
params.sorter = RequestSorter(SORT_DESC, '', 'date_sent');
params.limit = messagesPerPage;
params.filters = [
RequestFilter('', 'date_sent', isLoadNew || date == 0 ? 'gt' : 'lt', date)
];
return getMessages(_cubeDialog.dialogId!, params.getRequestParameters())
.then((result) {
lastPartSize = result!.items.length;
return result.items;
})
.whenComplete(() {})
.catchError((onError) {});
}
In our sample, we use it for loading messages by pages and you can use it for loading new messages.
Can you receive messages after successful reconnection? I mean messages sent after reconnection, not messages sent when a user was offline. To avoid the inconsistency of data you can request new messages via an API request. You can request the messages with the
date_sent
more than received last message'sdateSent
. You can use the next request for it:Future<List<CubeMessage>> getMessagesByDate(int date, bool isLoadNew) async { var params = GetMessagesParameters(); params.sorter = RequestSorter(SORT_DESC, '', 'date_sent'); params.limit = messagesPerPage; params.filters = [ RequestFilter('', 'date_sent', isLoadNew || date == 0 ? 'gt' : 'lt', date) ]; return getMessages(_cubeDialog.dialogId!, params.getRequestParameters()) .then((result) { lastPartSize = result!.items.length; return result.items; }) .whenComplete(() {}) .catchError((onError) {}); }
In our sample, we use it for loading messages by pages and you can use it for loading new messages.
I can receive messages after reconnected.
btw, I can use this function for a dialog, but I also want to update the recent dialogs screen where the latest messages for dialogs will be displayed correctly. This function cannot do that.
you can refresh the list of the dialogs in a similar way by requesting dialogs by filtering them by updated_at
field (this field updates after sending the message to this dialog). The request can look similar to the next:
var lastUpdateTime; // some time point in seconds when the last message was received or dialogs requested
Map<String, dynamic> additionalParams = {
"updated_at[gt]": lastUpdateTime
};
getDialogs(additionalParams).then((dialogs) async {
logTime("Success GET_DIALOGS: $dialogs");
});
no activity for a long time. closing...
Specify the sample to which the issue belongs (use [x]): [] Chat sample [] P2P Calls sample [] Conference Calls sample
Platform (use [x]) [] Android [] iOS [] macOS [] Windows [] Web [] Linux
Device info Manufacture: Model: OS version:
Describe the bug:
Steps to Reproduce:
Logs:
or Gist log
Actual result: Sometimes offline messages are not sent to the device after reconnected
Expected behavior: offline messages are always sent to the device after reconnected
Additional info Add any other context about the problem here.