Jason Yu
Jason Yu

Reputation: 308

3D touch shortcut application:didfinishlaunchingwithoptions: performActionForShortcutItem: Execution order

If your app hasn't launched, and you click home shortcut item to launch your app, which method would be called first?

Is application:didFinishLaunchingWithOptions:

or

application:performActionForShorcutItem:completionHandler:

?

Upvotes: 1

Views: 1261

Answers (1)

wj2061
wj2061

Reputation: 6885

If you launch your app with 3D-touch shortcut ,the method:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool  

will be called first.
If this method return true ,the method :

func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: Bool -> Void)

will be called next.
But if you return false with the first method ,the second method will not be called.

If your app is already launched,you use 3D-touch shortcut to enter your app,only the second method will called.

See more details in Apple's Demo

Upvotes: 1

Related Questions