2

performActionFor shortcutItem gets called in my SceneDelegate if the app has already launched, but it doesn't get called if the app actually launches from a shortcut item. Why is this?

Doug Smith
  • 29,668
  • 57
  • 204
  • 388

1 Answers1

4

You can get the ShortcutItems from willConnectTo function in sceneDelegate when the app is launched from shortcut item (and when there is no instance of app is in background)

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
if let shortcutItems = connectionOptions.shortcutItem{
    }
}
  • Hey, is this all there is to it? I have quick actions set up and working when the app is running via func windowScene(.. performActionFor shortcutItem..), but since that doesn't work when the app isn't launched, I was looking for a way to fix it. And I can't seem to get what you suggested to work. I added if let shortcutItems = connectionOptions.shortcutItem{ UIApplication.shared.windows.first?.rootViewController?.alert(title: shortcutItems.debugDescription) } or tried saving the value to user defaults to test it and it does nothing. Any clues? – CristianMoisei Oct 23 '20 at 02:30