应用程序关闭时的iOS任务 [英] iOS task when application is closed

查看:70
本文介绍了应用程序关闭时的iOS任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个通过ajax将文件上传到服务器的应用程序. 问题是用户很可能有时无法连接互联网,而客户端希望在用户恢复连接时安排ajax调用.用户有可能在离线时安排文件上传并关闭应用程序.在关闭应用程序时(不在后台)可以进行ajax调用吗? 当应用程序在后台运行时,我们可以使用background-fetch进行操作,但是在应用程序关闭时我从来没有遇到过要执行任何操作的问题.

I am building an app which uploads files to the server via ajax. The problem is that users most likely sometimes won't have the internet connection and client would like to have the ajax call scheduled to time when user have the connection back. This is possible that user will schedule the file upload when he's offline and close the app. Is it possible to do ajax call when the application is closed (not in background)? When app is in the background, we can use background-fetch but I have never faced a problem to do something when app is closed.

推荐答案

简短的回答是否",您的应用在终止后将无法运行代码.

The short answer is no, your app can't run code after being terminated.

您可以在AppDelegateapplicationWillTerminate中运行代码,但是该方法主要用于保存用户数据和其他类似任务.

You can run code in your AppDelegate's applicationWillTerminate, but that method is mainly intended for saving user data and other similar tasks.

另请参见此答案.

这篇关于应用程序关闭时的iOS任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆