0

I am looking to synchronize to server at every 10 secs. When i terminates app then applicationDidEnterBackground called but i need to countinuosly run nstimer background to fetch data from server. In my case if app terminates then it won't be called any background fetching until i rerun the project. Is there anything possible to run method countinuosly even after terminating app?

  • no buddy u can not continue when application terminates. U have to maintain sync status like stop n resume sync feature! – hament miglani Jun 06 '17 at 13:06
  • You design is wrong, you should not be polling your server every 10 seconds. Doing this will drain the battery and therefor Apple does not allow any timer in the background. Most apps don't run in the background, only music, voip, location and accessory app run in the background. You server should inform you app of changes, not the other way around. Read about silent push notification and background refresh. – rckoenes Jun 06 '17 at 13:06
  • @rckoenes silent push notification even not works if user user forcefully terminates app! – hament miglani Jun 06 '17 at 13:07
  • @hamentmiglani true, but if the user kills your app (s)he has a reason for it. But iOS will launch your apps if you set the [`content-available`](https://stackoverflow.com/questions/34291002/can-apples-silent-push-notifications-launch-my-app-in-the-background) – rckoenes Jun 06 '17 at 13:08
  • Then which method is better to do sync mechanism? – Mahaveer Bubanale Jun 06 '17 at 13:32
  • Any parallel methods which call server at every 10 secs? – Mahaveer Bubanale Jun 06 '17 at 13:33
  • 1
    @hamentmiglani Content-available will not relaunch a terminated app. Only Pushkit will relaunch a terminated app and that is only for VoIP apps. – Paulw11 Jun 06 '17 at 13:42
  • @MahaveerBubanale no, there is no way to poll a server every 10 seconds and as rckoenes pointed out this is for good reason. Use a push notification with content-available and and a message payload. The message will be shown to the user if the app is terminated and delivered to the app if it is suspended. – Paulw11 Jun 06 '17 at 13:44
  • @MahaveerBubanale Polling every ten seconds is awful for battery life, amongst other things. Don't do that. – bbum Jun 06 '17 at 21:37
  • But there is any better solution to achieve this? How whatsapp, skype and other apps do to sync to server at min amount of time? – Mahaveer Bubanale Jun 07 '17 at 03:48

0 Answers0