1
votes

I have an instant messaging app in iOS. I want to use push notification to let the user know if he has received a message while the app is minimized. Initially i ve implemented the app such that when the app is minimized, the app informs my server which in turn contacts the APNS to inform that a message is received.But there is a delay for the app to inform the server. Hence if the user minimizes the app and , at the same time a message is being sent to him, he does not get the notification since my server is still sending the message to the app and not the APNS.

I am wondering how this scenario is overcome in chat apps. Are they sending all chat messages to APNS irrespective of whether the user has minimized the app or not. If i send all messages to APNS will that be a good design?

1

1 Answers

5
votes

On iOS, you can't rely on any processes that are working when the app is "minimized" (actually in background). Your process can be killed by the OS for a variety of reasons and in any case, unless you qualify for exceptional extended background processing, your app can not process for more than 10 minutes.

Typically, for a chat-type app, every time a message is received by a client, the same client sends back a message to let the server know that it has received said message. This way, if your server doesn't get a signal that the message was received after a few seconds, you can assume that the app is not running on the device and can send the message via push instead.

There is no need to use excessive processing on the client which will drain the battery and there is no need to send a push for every single message.