Search code examples
androidioschatquickblox

Quickblox chat between iOS and Android


I implemented the Quickblox chat on my iOS app and another developer has implemented the same application on the Android app.

When I am talking iOS device to iOS device, everything happens normally, messages are sent, received, listed in my view normally.

When the conversation is between Android device to Android device, all also occurs normally, everything happens perfectly.

The problem is when we try to talk between iOS device and Android device. I get push on my device and when I enter the chat, the message is not always listed on the first time I enter in the chat view. When I'm already in view and I get a message, I need to get out of it and back, so that the message appears, but it appears intermittently.

Is there any configuration needed, conversion, so that the cross-platform chat work properly? This is a known bug?

Thank U!


Solution

  • Finally I figured out what was occurring in my code.

    In iOS, my iPhone was with Settings > General > Date & Time > Time Zone - Automatically switch turned off. My clock was 2 minutes early, then when the list messages with dialog request was being sent, I used [now timeIntervalSince1970], and I didn't receive all the messages, so I had to wait 2 minutes to enter in the chat again, then all the messages were listed. With date, time and time zone being set up automatically, everything goes fine.

    Objective-C Request:

    NSMutableDictionary *extendedRequest = [NSMutableDictionary new];
    NSDate *now = [NSDate date];
    extendedRequest[@"date_sent[lte]"]= @([now timeIntervalSince1970]);
    extendedRequest[@"sort_desc"]= @"date_sent";
    
    //get the most recent 100 messages
    extendedRequest[@"limit"] = @(100);
    
    [QBChat messagesWithDialogID:self.dialog.ID extendedRequest:extendedRequest delegate:self];
    

    In Java, we only had to comment this if:

    if (messageHistory == null || !messages.get(messages.size() - 1).getId()
    .equals(messageHistory.get(messageHistory.size() - 1).getId())) {
      //stuff here
    }
    

    Now, everything works fine! Thank you for the answers.