OGeek|极客世界-中国程序员成长平台

标题: ios - 使用在后台运行的应用程序打开文件 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 20:06
标题: ios - 使用在后台运行的应用程序打开文件

我正在创建一个应用程序,当我在该文件的“打开方式”对话框中点击我的应用程序图标时,该应用程序应该能够打开该文件。为了做到这一点,我假设我可以通过 AppDelegate 中的 application(_:didFinishLaunchingWithOptions 或 application(_:willFinishLaunchingWithOptions 获取文件数据,从那里我可以获取外部文件的 url。应用启动时。

但是,当我在文件的“打开方式”对话框中点击其图标时,我的应用程序应该已经在后台运行。因此, application(_:didFinishLaunchingWithOptions 或 application(_:willFinishLaunchingWithOptions 永远不会被调用,因为在这种情况下应用程序将从后台返回,因此只有函数 applicationWillEnterForeground(_ AppDelegate 被调用。

有什么想法可以解决这个问题吗? (对不起我的英语不好)



Best Answer-推荐答案


查看 application(_penptions。当您的应用程序已经运行而不是 application(_:didFinishLaunchingWithOptions 当另一个应用程序想要打开您的应用程序时,会调用此方法。

在此处查看 Apple 的文档:https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application

关于ios - 使用在后台运行的应用程序打开文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50125507/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4