Let's say we have an iOS app that communicates with a web service. Some requests are delegated to another web service, so that a HTTP 200 status code is returned immediately while the operation is in progress on the other side:
|iOS app| |Main service| |Delegate service|
| request | |
|------------------->|_ delegate |_
| | |----------------->| |
| HTTP 200 | | accepted | |
|<-------------------|_|<-----------------| |
| | | |
| | | |
| status? | | |
|------------------->|_ | |
| | | | |
| pending | | | |
|<-------------------|_| | |
| | | |
| | finished | |
| |<-------------------|_|
| | |
| status? | |
|------------------->|_ |
| | | |
| finished | | |
|<-------------------|_| |
| | |
| | |
These requests can last from 20 seconds up to 2 minutes so we can afford to poll the server every 15-20 seconds.
Which are the best practices to implement such scenario? Could Apple reject the app if we decide to implement a polling strategy of one request every 20 seconds limited to 6 requests?
Unfortunately there is no server support either for a long polling strategy (it's not under our control). The server simply returns a status JSON on each request.
We are trying to avoid using push notifications, since these requests are kind of low-level tasks and the user does not have to be explicitly involved.
I would recommend you to try a Long Polling strategy, which has been discussed in previous threads : long polling in objective-C . Also have a look at this TCP-based RPC server (Erlang or something similar?) for iOS/Android app communication
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With