I have a messaging app. Every time I try to send a message without internet connection, backgrounding my app after it, it will not send the message when the internet connection is recovered (unless I put my app in foreground again).
I have a reachability test that tries to send the messages again as soon as the connection is reestablished. However, the reachability test stops working as soon as the app is put on background.
I know it seems like a duplicate, but all the responses I could find in stack overflow says that it is impossible to execute things in background on iOS. The iOS documentation says the same. However, Telegram can handle that somehow, so I'm sure there is a way to do that.
The test I'm doing with telegram is:
- Put in airplane mode
- Send a message
- Background telegram
- Wait for a minute. It does not matter how much time you wait, but I just want to be sure that the app is already terminated.
- Unselect airplane mode
- The message will be sent with the app in background
How is telegram executing code in background whenever it wants to?