How to run a Background Task on iOS application wh

2019-03-06 15:50发布

I'm using a third party library "Reachability.swift"

https://github.com/ashleymills/Reachability.swift

Followed this blog post to identify network event using Notification Center, So the change in network event can be identified dynamically in the foreground

https://blog.pusher.com/handling-internet-connection-reachability-swift/

My Requirement:-

I need to run a background service that uses Alamofire(Information not needed for alamofire) to push the locally saved SQLite data to the server whenever internet connection status is Active

Important note:- iOS Application should not run in the foreground, everything should happen in the background

Please help me out to understand the topic, Thank in advance!

1条回答
你好瞎i
2楼-- · 2019-03-06 16:49

You should fully read and understand Apple's excellent documentation on background execution: Background Execution

There are only a few application types that are allowed to run permanently in background mode:

  • Apps that play audible content to the user while in the background, such as a music player app
  • Apps that record audio content while in the background
  • Apps that keep users informed of their location at all times, such as a navigation app
  • Apps that support Voice over Internet Protocol (VoIP)
  • Apps that need to download and process new content regularly
  • Apps that receive regular updates from external accessories

Apps of those types must ask for specific permission to run in the background. Declaring a wrong type for your app may lead to app rejection by Apple.

查看更多
登录 后发表回答