问题描述
我正在使用第三方库"Reachability.swift"
I'm using a third party library "Reachability.swift"
https://github.com/ashleymills/Reachability.swift
此博客文章使用Notification Center识别网络事件,因此可以在前台动态识别网络事件的变化
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/
我的要求:-
我需要运行一个使用 Alamofire (alamofire不需要的信息)的后台服务,以在Internet连接状态为活动"时将本地保存的SQLite数据推送到服务器上
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
重要说明:-iOS应用程序不应在前台运行,所有事情都应在后台运行
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!
推荐答案
您应该完全阅读并了解Apple出色的后台执行文档:背景执行
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:
- 在后台播放可听内容的应用程序,例如音乐播放器应用程序
- 在后台录制音频内容的应用
- 始终使用户知道其位置的应用程序,例如导航应用程序
- 支持互联网协议语音(VoIP)的应用
- 需要定期下载和处理新内容的应用
- 从外部附件接收定期更新的应用
这些类型的应用必须请求特定的权限才能在后台运行.为您的应用声明错误的类型可能会导致Apple拒绝应用.
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.
这篇关于当检测到Internet连接时如何在iOS应用程序上运行后台任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!