I have seen this behavior in many chat application. What i notice is that, whenever you are using the app means when the app is in foreground, then if somebody send you the message, it appears on the chat list.
But if you are not using your application means the app is in background and u r not log out yet, then if somebody send you the message, it appears on the notification with some sound. So i want to know how can we detect that the app we are using is in background or in foreground, so based on this i can perform action.