Skip to content

iOS 9 Experiments - New API Components - Shortcut Quick Action API with 3DTouch.

Notifications You must be signed in to change notification settings

Sweefties/iOS9-NewAPI-3DTouch-QuickActions-Example

Repository files navigation

iOS 9 - New API - 3DTouch - Quick Actions Example

iOS 9~ Experiments - New API Components - Shortcut Quick Action API with 3DTouch.

Example

Requirements

  • = XCode 8.0

  • = Swift 3.

  • = iOS 9.0.

  • = 3DTouch Devices.

Tested on iOS 9.0, iOS 10 Simulators iPhone 6S, 6S Plus, 7.

Important

this is the Xcode 8 / Swift updated project.

Configure your app Info Targets

Usage

To run the example project, download or clone the repo.

Example Code!

/// Define quick actions type
enum QuickActionsType: String {
    case First =     "quickactions.domain.first"
    case Second =   "quickactions.domain.second"
    case Third =    "quickactions.domain.third"
}
  • performActionForShortcutItem example
/// Calls - user selects a Home screen quick action for app
func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {
    // perform action for shortcut item selected
    let handledShortCutItem = QuickActionsForItem(shortcutItem)
    completionHandler(handledShortCutItem)
}
  • didFinishLaunchingWithOptions example
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // set if app launched from shorcut with boolean
    var appLaunchedFromShortCut = false
    // check current shortcut item
    if let currentShorcutItem = launchOptions?[UIApplicationLaunchOptionsShortcutItemKey] as? UIApplicationShortcutItem {
        appLaunchedFromShortCut = true
        QuickActionsForItem(currentShorcutItem)
    }
    // return false if app already launched
    return !appLaunchedFromShortCut
}
  • Build and Run!
  • Switch to Home screen
  • Simulator : SBShortcutMenuSimulator
  • CAUTION! : make sure to uninstalled it after test!
  • Devices : with future iPhone 6s and others 3DTouch devices!

About

iOS 9 Experiments - New API Components - Shortcut Quick Action API with 3DTouch.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages