2

I am making an app which displays data from a Website/Blog. User can follow any author. Requirement is , when the app goes to background 1) First a GET call for the data should run 2) After analysing the data, proper notifications should be displayed

I've read about Background Fetch details. But it states that OS will set it's own timing to run that code. Ive checked the app and it has just displayed notifications one time in 3 days.

Can any one tell me how to do background fetch properly and display notifications accordingly. Any good article link will be appreciated too.

Talha Ahmad Khan
  • 3,416
  • 5
  • 23
  • 38
  • were you to able to run a get call in background mode ? I am using alamofire to hit get request and i'm not getting any response from alamofire. Do you know anything about that ? – Preeti Rani Aug 17 '18 at 06:43
  • kindly check the accepted answer. We can't run GET calls this way. Either you have to use Push Notifications, Push Kit or Background Fetch service – Talha Ahmad Khan Aug 27 '18 at 04:27

1 Answers1

3

You read right, in iOS you cannot run in background indefinitely, instead iOS will monitor the usage pattern of your application and launch your application if certain criteria matches (like battery, time etc).

you can check this link to understand more about background executions, https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html

For implementation, checkout the following articles, its really useful

https://www.raywenderlich.com/92428/background-modes-ios-swift-tutorial

https://www.appcoda.com/ios7-background-fetch-programming/

https://blog.newrelic.com/2016/01/13/ios9-background-execution/

Hope it helps!

Ramesh Lingappa
  • 2,448
  • 20
  • 33