Instance Method

application:performActionForShortcutItem:completionHandler:

Called when the user selects a Home screen quick action for your app, except when you’ve intercepted the interaction in a launch method.

Declaration

- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded))completionHandler;

Parameters

application

Your shared app object.

shortcutItem

The quick action for which you are providing an implementation in this method.

completionHandler

Call this block after your quick action implementation completes, returning YES or NO depending on the success or failure of your implementation code.

succeeded

A Boolean value indicating whether or not your implementation succeeded.

Discussion

Implement this method to respond to the user’s selection of a Home screen quick action for your app; call the completion handler, with an appropriate Boolean value, when finished.

It’s your responsibility to ensure the system calls this method conditionally, depending on whether or not one of your app launch methods (application:willFinishLaunchingWithOptions: or application:didFinishLaunchingWithOptions:) has already handled a quick action invocation. The system calls a launch method (before calling this method) when a user selects a quick action for your app and your app launches instead of activating.

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. Perform this check in your application:willFinishLaunchingWithOptions: or application:didFinishLaunchingWithOptions: method by checking for the UIApplicationLaunchOptionsShortcutItemKey launch option key. The UIApplicationShortcutItem object is available as the value of the launch option key.

If you find that your app was indeed launched using a quick action, perform the requested quick action within the launch method and return a value of NO from that method. When you return a value of NO, the system does not call the application:performActionForShortcutItem:completionHandler: method.

See Also

Continuing User Activity and Handling Quick Actions

- application:willContinueUserActivityWithType:

Tells the delegate if your app takes responsibility for notifying users when a continuation activity takes longer than expected.

- application:continueUserActivity:restorationHandler:

Tells the delegate that the data for continuing an activity is available.

- application:didUpdateUserActivity:

Tells the delegate that the activity was updated.

- application:didFailToContinueUserActivityWithType:error:

Tells the delegate that the activity could not be continued.