0

i have been looking unsuccessfully on trying to effectively schedule a task on IOS which needs to run every N minutes. Typically in Android, you can achieve this my using the AlarmManager and the setAlarmClock method which will be called even if the phone is dozing/sleeping and it works like a charm. In IOS i have found something close but the problem is that you cannot execute the code you want. Basically you can play alarm sound. I need to have the possibility to send a webrequest to a central server every N minutes even if the IPhone is sleeping.

Is it possible?

Thank you for your time

  • 1
    You can achieve it by using `remote-notification` background mode and triggering the download by push notification with `content-available` key with its value set to `1`. More on background modes [here](https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html) – mag_zbc Apr 10 '18 at 10:13
  • Thanks for your answer. I will try to find examples on how to implement the remote-notification. – Rabih Sarieddine Apr 10 '18 at 10:49
  • So if my understanding is correct, my backend server application needs to send the push message (through the apple push notification gateway) to my IOS device which in turn will trigger the downlad request. Is there a solution that does not depend on remote server? let me explain you why: if the network is not available i need to write the data on a local file. So let's say that every N minute i have to send the request. If the network is not avaible at that moment, i store the data locally until next time. If the network is not available, i guess that the push notification will not arrive? – Rabih Sarieddine Apr 10 '18 at 10:56
  • Unfortunately, iOS doesn't support waking your app on your own schedule. Server-sent remote notifications are the only way to ask the system to wake your app so it can fetch new content when you need it. – John Wickham Apr 10 '18 at 13:46

0 Answers0