Strictly every 3 minutes you need to send to the server a request with information about the actions of the client. For example, did he press a specific button, and if he did, then send a request for receiving data. The state of the button must be monitored even if the user has turned off the application. (It may seem that there is no sense in keeping track of the button in the background - the button is just for the sake of example, the task will require monitoring the status even in the background)

I know that there are background modes , of which for me (as I understand it), either background fetch or executing finite-length tasks is suitable. But at once the amendment, in the background fetch I can set the query execution interval, setMinimumBackgroundFetchInterval , which does not guarantee strictly every 3 minutes . And the doubts about executing finite-length tasks are that I need to complete 2-3 requests (as I understood through NSTimer), and the task itself is not a long one.

What should be used? Maybe I should do this through NSURLSession at NSURLSession , but then in which direction should I dig?

  • if absolutely every three is necessary, then probably only if you keep the application active through audio playback. At the same time, it is necessary that you have some kind of audio, which in the opinion of the reviewers from the epl will make sense (not an empty track). I would send every three minutes through the audio to notify the user that an update is taking place. (like running applications, every kilometer tells you that you ran another kilometer) - Max Mikheyenko
  • @MaxMikheyenko, as always, is glad to see you: W, will there be any problems with the fact that I notify the user not through a push, but by some other methods? - user204104
  • I will honestly say that I didn’t do this myself - I’ve recently stumbled upon an article where someone explained how they cranked up such a focus. I don’t seem to have any problems, but to be honest, I would advise you to do background fetch (although it does not guarantee sending time exactly) - Max Mikheyenko
  • @MaxMikheyenko if you try to do bg fetch, then how would you recommend testing it? I set a minimum send interval of 3 minutes, in the form of a test I made some correct asynchronous request to Google, and immediately in closing the request, I gave a local notification about the time of the action, I launched no results only if I simulated the request - user204104
  • check that your local notifications work - in ios8 they added such a chip that you must first ask the user for permission; or after receiving the request, save that thread in user defaults, which you can check later; or make a server on localHost and check from the server that the request came - Max Mikheyenko

1 answer 1

In the background, the system will not allow you to send data every 3 minutes all the time. You can read more about working in the background: https://www.raywenderlich.com/92428/background-modes- ..

There is a hack with audio playback (when an empty track is played), the application lives and you can send requests at the right time. If the user does not interrupt playback and the application must necessarily be in the background.

Or, for example, track by location. The locationManager has a property that allows you to run the delegate method at regular intervals, wake up the application and send data. If I'm not mistaken, this is only possible with ios8.

The only BUT, in the probability that such an application will fall into the app store tends to zero)