gpt4 book ai didi

ios - didFinishLaunchingWithOptions 后台恢复或完全启动

转载 作者:行者123 更新时间:2023-11-29 10:21:46 27 4
gpt4 key购买 nike

didFinishLaunchingWithOptions 中,您如何知道应用程序是从前台恢复还是新启动?我需要知道这个方法,因为有 2 个任务要运行,具体取决于 launchOptions 是什么以及应用程序处于什么状态。谢谢。

最佳答案

来自 Test if app did become active from a UILocalNotification :

When an app enters the foreground from the background it does not trigger applicationDidFinishLaunchingWithOptions. It does, however, call applicationWillEnterForeground and applicationDidBecomeActive. This can be verified with a couple of NSLogs.

因此可以知道应用程序是从后台返回还是新启动。


来自 the developer page :搜索 didFinishLaunchingWithOptions,您将拥有所有选项。此外,他们有这张图表告诉应用程序具有的所有阶段:

State changes in an iOS app

您正在寻找的是 Inactive 状态:

The app is running in the foreground but is not receiving events. (It may be executing other code though.) An app usually stays in this state only briefly as it transitions to a different state. Upon entering this state, the app should put itself into a quiescent state with the expectation of moving to the background or active state shortly.

或暂停状态:

The app is in memory but is not executing code. The system suspends apps that are in the background and do not have any pending tasks to complete. The system may purge suspended apps at any time without waking them up to make room for other apps.

看完这篇我不认为你需要的是背景状态

关于ios - didFinishLaunchingWithOptions 后台恢复或完全启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34728354/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com