ios3dtouchuiapplicationshortcutitem

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:

?


Solution

  • 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