应用程序图标上的快捷方式项不适用于iOS 13 [英] Shortcut item on app icon not working with iOS 13
问题描述
为了支持应用程序图标上的快捷方式项,我们在 SceneDelegate
中实现了以下方法:
To support shortcut items on the app icon we've implemented the following method in SceneDelegate
:
func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void)
通过此类快捷方式项杀死并启动该应用程序时,不会调用此方法(仅显示主屏幕).但是,当应用程序在后台运行时,将调用此方法,并且一切都会按预期进行.
This method does not get called when the app is killed and launched through such an shortcut item (it just shows the main screen). However when the app is running and in the background this method gets called and everything works as expected.
我还检查了 didFinishLaunchingWithOptions
中的 AppDelegate
,以查看 launchingOptions
中是否存在快捷方式项,但它们为 nil .
I've also checked AppDelegate
in didFinishLaunchingWithOptions
to see whether there's a shortcut item in launchingOptions
but they are nil
.
推荐答案
在以下位置检查ShortcutItem
Check for shortcutItem in
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
if let shortcutItem = connectionOptions.shortcutItem {
shortcutItemToProcess = shortcutItem
}
}
然后在
func sceneDidBecomeActive(_ scene: UIScene) {
if let shortcutItem = shortcutItemToProcess {
shortcutItemToProcess = nil
}
}
这篇关于应用程序图标上的快捷方式项不适用于iOS 13的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!