【问题标题】:How to know whether didFinishLaunchingWithOptions is called because of user launching the app or the system如何知道是否因为用户启动应用程序或系统而调用了 didFinishLaunchingWithOptions
【发布时间】:2014-04-10 18:33:39
【问题描述】:

我的应用在必需的后台模式中使用 IP 语音“voip”模式,因此每当应用崩溃或系统在后台终止它时,系统就会偶尔自动运行它。

我的问题是,如何知道 didFinishLaunchingWithOptions 是否因为用户启动应用程序或系统而被调用。因为如果应用程序由系统自动运行,我需要关闭不同的事件。

注意。对于任何一种情况,launchOptions 字典都会返回 null

【问题讨论】:

    标签: ios objective-c


    【解决方案1】:

    您可以查看[UIApplication sharedApplication].applicationState。在后台运行时,它将返回UIApplicationStateBackground

    【讨论】:

      【解决方案2】:

      您需要检查launchOptions 字典的内容。

      实际上有人已经记录了所有可能的选项here

      【讨论】:

      • 对于任何一种情况,launchOptions 字典都返回 null
      猜你喜欢
      • 2012-11-01
      • 1970-01-01
      • 2017-02-11
      • 2014-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-10
      • 1970-01-01
      相关资源
      最近更新 更多