1

When you hard press an app icon and select one of its Quick Actions on the home page, you have two options:

1. The app was already running (in the background)

In this case, the Quick Action is handled by performActionForShortcutItem:completionHandler:

2. Your app is being launched

In this case, did/willFinishLaunching is called and then performActionForShortcutItem:completionHandler:

I read in an article that you have to check in did/willFinishLaunching if the app is launched by a Quick Action, and if so, handle it there and return false so performActionForShortcutItem:completionHandler: won't be called again. I was wondering why this approach is better? Is this because otherwise your whole app launched and THEN the Quick Action is handled instead of directly handling the Quick Action.

AaoIi
  • 8,288
  • 6
  • 45
  • 87
  • The documentation for `application:performActionForShortcutItem:completionHandler:` explains the reasons why you might want to do it that way. – dan Nov 06 '15 at 16:09

1 Answers1

1

As Dan pointed out in the comments, the Apple Documentation explains why we should program it this way.

The requested quick action might employ code paths different than those used otherwise when your app launches. For example, say your app normally launches to display view A, but your app was launched in response to a quick action that needs view B. To handle such cases, check, on launch, whether your app is being launched via a quick action.

Ali Saeed
  • 1,519
  • 1
  • 16
  • 23