应用程序关闭时如何使用动态快速操作?

问题描述 投票:0回答:1
如何在iOS中使用动态快速动作? 如果应用程序正在多任务处理,我可以触发我的方法。但是,如果该应用程序不在后台运行,则它不起作用。 我正在用

applicationWillResignActive

/

sceneWillResignActive

设置我的快速操作。 我正在处理我的方法:

func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void)

func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void)
任何建议?

仅在应用程序运行时才调用表演方法(在后台0中。如果不是。如果不是在应用程序启动时,则需要检查捷径是否在didfinishlaunchingwithoptions或willfinishlaunchingwithoptions中。快捷方式将在启动项目中。
像这样的东西:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. if let shortcutItem = launchOptions?[UIApplication.LaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem{ handleShortcutItem(shortcutItem) } return true }

ios swift shortcut
1个回答
3
投票

对于场景委托您可以使用此代码:

handleShortcutItem
    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.