-1

I am creating a new ios app and it needs to call web api and update badge number every hour after user manually kill the app or it's in background. I have searched long time but couldn't find any great solution.

I do not want to use push notification. Scalability is too huge for every device because I need to do it every hour.

Rob
  • 415,655
  • 72
  • 787
  • 1,044
Passionate.C
  • 233
  • 3
  • 20
  • The two alternatives are either "background fetch" (see [App Programming Guide for iOS: Fetching Small Amounts of Data Opportunistically](https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/TP40007072-CH4-SW56), in which you have no control over the frequency of the fetches) or push notifications (where you don't poll the server every hour, but instead the server tells your app when there are updates). I know this isn't what you're looking for, but those are the options. – Rob Apr 21 '18 at 04:30
  • Also, btw, you say "after app is terminated": Do you really mean when it's terminated (i.e. the user manually killed the app), or do you just mean when the user leaves the app (i.e. it's suspended in the course of its normal lifecycle)? If user explicitly kills the app, that can affect normal background operations... – Rob Apr 21 '18 at 04:34
  • @Rob "after app is terminated" means both of what you are saying. Do you think if there is a way that I can do what I want? I heard I can use AlarmManager for it. – Passionate.C Apr 21 '18 at 20:28
  • AlarmManager is Android. And in iOS, when a user kills app, effectively saying "stop this app from running", it will prevent many background operations from proceding. – Rob Apr 21 '18 at 20:44
  • By the way, I don't understand your repeated assertions that you don't want to do push notifications because you don't want that to happen every hour. The whole idea behind push is that it happens only when there is something to be pushed, not every hour. – Rob Apr 21 '18 at 20:50
  • @Rob Totally I want to reproduce the push notifications because the app receives already many push notifications, that's why I want to implement the background service and use badge updates. – Passionate.C Apr 22 '18 at 22:38

3 Answers3

1

When app is terminated you cannot do any operation until any external event occur to wake up like user open app or tap on APNS

REF : Perform background tasks when app is terminated

Abhishek Thapliyal
  • 3,497
  • 6
  • 30
  • 69
1

Apple is not allowing anything (except receiving notification) in terminated or closed state.

I think You can find your answer here

Hope it will help you.

  • Background fetch fires off periodically after the app is suspended. Just not once per hour.. – Rob Apr 21 '18 at 06:02
0

You can update badge number via push notification also. And Apple does not allow any thread in terminated mode.

kalpesh
  • 1,285
  • 1
  • 17
  • 30