如何知道应用程序是被用户还是 iOS 终止(后台 10 分钟后) [英] How to know whether app is terminated by user or iOS (after 10min background)

查看:25
本文介绍了如何知道应用程序是被用户还是 iOS 终止(后台 10 分钟后)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重启应用时如何知道应用是被用户终止还是被iOS终止>

How to know whether app is terminated by user or by iOS when restart app>

'By user' 的意思是通过双击主页按钮并按下 - 按钮".被用户杀死

'By user' means "by Double-clicking Home Button and pressing - button". killed by user

'By iOS'的意思是app变成后台运行状态,iOS在10分钟后终止app"

'By iOS' means "app become background running state, and iOS terminate app after 10 mins"

推荐答案

如果您的应用程序处于挂起状态,则无论是谁杀死了应用程序 iOS 或用户,applicationWillTerminate 将永远不会被调用.

If your app is in suspended state the applicationWillTerminate will never get called regardless who killed the app iOS or user.

您的 applicationWillTerminate 只会在您的应用程序处于后台并且它被杀死(由 iOS 或用户)时调用,术语后台意味着它在后台运行而不是处于挂起状态.

Your applicationWillTerminate will only call when your app is in background and it gets killed (either by iOS or user) the term background means that it is running in background not in suspended state.

只需阅读 这个参考

applicationWillTerminate:让您知道您的应用程序正在被终止.如果您的应用暂停,则不会调用此方法.

applicationWillTerminate:—Lets you know that your app is being terminated. This method is not called if your app is suspended.

这是各种状态的表格

后台 - 应用程序在后台并执行代码.大多数应用程序在被暂停的过程中会短暂进入此状态.但是,请求额外执行时间的应用程序可能会在此状态下保持一段时间.此外,直接在后台启动的应用程序会进入此状态而不是非活动状态.有关如何在后台执行代码的信息,请参阅后台执行.

Background - The app is in the background and executing code. Most apps enter this state briefly on their way to being suspended. However, an app that requests extra execution time may remain in this state for a period of time. In addition, an app being launched directly into the background enters this state instead of the inactive state. For information about how to execute code while in the background, see Background Execution.

这篇关于如何知道应用程序是被用户还是 iOS 终止(后台 10 分钟后)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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