Messages are not delivered once one of users goes offline.
If you use 1 to 1 chat you need to logout from Chat when application goes to background and login again when you go foreground. In this case messages will be delivered without any issues.
In case you are using chat room you need to enter the room in order to receive message history. If you wish to implement this logic you need to join particular chat room when application comes from background. For example, if application goes background you need to exit the room, then QBChat instance. When application goes foreground you need to join QBChat instance, then join chat room. As a result you receive the full message history. All these actions are not shown to the users.