{"id":18839777,"url":"https://github.com/maximbilan/3d-touch-quick-actions-demo","last_synced_at":"2026-03-05T00:36:14.551Z","repository":{"id":76125690,"uuid":"55702692","full_name":"maximbilan/3D-Touch-Quick-Actions-Demo","owner":"maximbilan","description":"iOS 3D Touch: How to add quick actions","archived":false,"fork":false,"pushed_at":"2018-09-22T09:53:46.000Z","size":767,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T07:03:18.661Z","etag":null,"topics":["3d-touch","ios","quickactions","swift","turorial"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maximbilan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-07T14:46:09.000Z","updated_at":"2021-02-23T06:54:03.000Z","dependencies_parsed_at":"2023-02-25T05:30:40.427Z","dependency_job_id":null,"html_url":"https://github.com/maximbilan/3D-Touch-Quick-Actions-Demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2F3D-Touch-Quick-Actions-Demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2F3D-Touch-Quick-Actions-Demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2F3D-Touch-Quick-Actions-Demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximbilan%2F3D-Touch-Quick-Actions-Demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maximbilan","download_url":"https://codeload.github.com/maximbilan/3D-Touch-Quick-Actions-Demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837279,"owners_count":21169374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d-touch","ios","quickactions","swift","turorial"],"created_at":"2024-11-08T02:44:02.303Z","updated_at":"2026-03-05T00:36:09.499Z","avatar_url":"https://github.com/maximbilan.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iOS 3D Touch: How to add quick actions\n\nRecently \u003ci\u003eApple\u003c/i\u003e has provided a new technology \u003ci\u003e3D Touch\u003c/i\u003e for \u003ci\u003eiPhone 6S\u003c/i\u003e and \u003ci\u003e6S Plus\u003c/i\u003e. Which contains 3 new features for your applications.\n\n![alt tag](https://raw.github.com/maximbilan/3D-Touch-Quick-Actions-Demo/master/img/1.png)\n\n\u003ch4\u003eQuick Actions\u003c/h4\u003e\n\nQuick Actions let users do the things they do most often, faster and in fewer steps. Many of these actions can even be done with a single press, right from the Home screen.\n\n![alt tag](https://raw.github.com/maximbilan/3D-Touch-Quick-Actions-Demo/master/img/2.png)\n\n\u003ch4\u003ePeek and Pop\u003c/h4\u003e\n\nLet your users preview all kinds of content and even act on it — without having to actually open it. Users can then press a little deeper to Pop into content in your app.\n\n![alt tag](https://raw.github.com/maximbilan/3D-Touch-Quick-Actions-Demo/master/img/3.png)\n\n\u003ch4\u003ePressure Sensitivity\u003c/h4\u003e\n\nCreative apps can take advantage of the pressure-sensing display of \u003ci\u003eiPhone 6\u003c/i\u003e sand \u003ci\u003eiPhone 6s Plus\u003c/i\u003e in many ways. For example, they can vary line thickness or give a brush a changing style.\n\n![alt tag](https://raw.github.com/maximbilan/3D-Touch-Quick-Actions-Demo/master/img/4.png)\n\nMore information you can of course found on \u003ci\u003e\u003ca href=\"https://developer.apple.com/ios/3d-touch/\"\u003eApple\u003c/a\u003e\u003c/i\u003e. Guides, tutorials, examples, etc.\n\nI would like to tell about \u003ci\u003eQuick Actions\u003c/i\u003e, how to implement in application. Actions can be static or dynamic. Let’s start.\n\nFirst of all, we need to add \u003cb\u003eUIApplicationShortcutItems\u003c/b\u003e to \u003cb\u003eInfo.plist\u003c/b\u003e. Each child item should be a dictionary and must have at least these required keys:\n\n\u003cb\u003eUIApplicationShortcutItemType\u003c/b\u003e: a string which is sent to your application as a part of \u003ci\u003e\u003ca href=\"https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationShortcutItem_class/\"\u003eUIApplicationShortcutItem\u003c/a\u003e\u003c/i\u003e. It can be used in code to handle actions for different shortcut types.\n\n\u003cb\u003eUIApplicationShortcutItemTitle\u003c/b\u003e: a title of your action. Can be localized.\n\nAnd there are optional keys:\n\n\u003cb\u003eUIApplicationShortcutItemSubtitle\u003c/b\u003e: a subtitle of your action. Also can be localized.\n\n\u003cb\u003eUIApplicationShortcutItemIconType\u003c/b\u003e: an optional string which defines built-in icon type:\n\n```swift\nenum UIApplicationShortcutIconType : Int {\n  case Compose\n  case Play\n  case Pause\n  case Add\n  case Location\n  case Search\n  case Share\n  case Prohibit\n  case Contact\n  case Home\n  case MarkLocation\n  case Favorite\n  case Love\n  case Cloud\n  case Invitation\n  case Confirmation\n  case Mail\n  case Message\n  case Date\n  case Time\n  case CapturePhoto\n  case CaptureVideo\n  case Task\n  case TaskCompleted\n  case Alarm\n  case Bookmark\n  case Shuffle\n  case Audio\n  case Update\n}\n```\n\n\u003cb\u003eUIApplicationShortcutItemIconFile\u003c/b\u003e: an optional string specifying an image from \u003ci\u003eAssets Catalog\u003c/i\u003e or from the \u003ci\u003eBundle\u003c/i\u003e.\n\n\u003cb\u003eUIApplicationShortcutItemUserInfo\u003c/b\u003e: an optional dictionary of additional user information.\nLet’s try. Please add the next data to \u003ci\u003eInfo.plist\u003c/i\u003e:\n\n\u003cpre\u003e\n\u0026#60;key\u0026#62;UIApplicationShortcutItems\u0026#60;/key\u0026#62;\n\u0026#60;array\u0026#62;\n  \u0026#60;dict\u0026#62;\n    \u0026#60;key\u0026#62;UIApplicationShortcutItemIconType\u0026#60;/key\u0026#62;\n    \u0026#60;string\u0026#62;UIApplicationShortcutIconTypeShare\u0026#60;/string\u0026#62;\n    \u0026#60;key\u0026#62;UIApplicationShortcutItemTitle\u0026#60;/key\u0026#62;\n    \u0026#60;string\u0026#62;SHORTCUT_TITLE_SHARE\u0026#60;/string\u0026#62;\n    \u0026#60;key\u0026#62;UIApplicationShortcutItemType\u0026#60;/key\u0026#62;\n    \u0026#60;string\u0026#62;$(PRODUCT_BUNDLE_IDENTIFIER).Share\u0026#60;/string\u0026#62;\n  \u0026#60;/dict\u0026#62;\n  \u0026#60;dict\u0026#62;\n    \u0026#60;key\u0026#62;UIApplicationShortcutItemIconType\u0026#60;/key\u0026#62;\n    \u0026#60;string\u0026#62;UIApplicationShortcutIconTypeAdd\u0026#60;/string\u0026#62;\n    \u0026#60;key\u0026#62;UIApplicationShortcutItemTitle\u0026#60;/key\u0026#62;\n    \u0026#60;string\u0026#62;SHORTCUT_TITLE_ADD\u0026#60;/string\u0026#62;\n    \u0026#60;key\u0026#62;UIApplicationShortcutItemType\u0026#60;/key\u0026#62;\n    \u0026#60;string\u0026#62;$(PRODUCT_BUNDLE_IDENTIFIER).Add\u0026#60;/string\u0026#62;\n  \u0026#60;/dict\u0026#62;\n\u0026#60;/array\u0026#62;\n\u003c/pre\u003e\n\nAlso create \u003ci\u003eInfoPlist.strings\u003c/i\u003e:\n\n\u003cpre\u003e\n\"SHORTCUT_TITLE_SEARCH\" = \"Search\";\n\"SHORTCUT_TITLE_FAVORITES\" = \"Favorites\";\n\u003c/pre\u003e\n\nAnd what we got:\n\n![alt tag](https://raw.github.com/maximbilan/3D-Touch-Quick-Actions-Demo/master/img/5.png)\n\nLet’s implement handling of shortcuts. We need to create the next enumeration:\n\n```swift\nenum ShortcutIdentifier: String {\n  case Share\n  case Add\n \n  init?(fullType: String) {\n    guard let last = fullType.componentsSeparatedByString(\".\").last else { return nil }\n    self.init(rawValue: last)\n  }\n  \n  var type: String {\n    return NSBundle.mainBundle().bundleIdentifier! + \".\\(self.rawValue)\"\n  }\n}\n```\n\nAnd a method for handling \u003ci\u003e\u003ca href=\"https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationShortcutItem_class/\"\u003eUIApplicationShortcutItem\u003c/a\u003e\u003c/i\u003e. For example:\n\n```swift\nfunc handleShortCutItem(shortcutItem: UIApplicationShortcutItem) -\u003e Bool {\n  var handled = false\n  \n  // Verify that the provided `shortcutItem`'s `type` is one handled by the application.\n  guard ShortcutIdentifier(fullType: shortcutItem.type) != nil else { return false }\n  guard let shortCutType = shortcutItem.type as String? else { return false }\n\n  switch (shortCutType) {\n    case ShortcutIdentifier.Share.type:\n      // Handle shortcut 1 (static).\n      handled = true\n    break\n    case ShortcutIdentifier.Add.type:\n      // Handle shortcut 2 (static).\n      handled = true\n    break\n    default:\n    break\n  }\n\n  // Construct an alert using the details of the shortcut used to open the application.\n  let alertController = UIAlertController(title: \"Shortcut Handled\", message: \"\\\"\\(shortcutItem.localizedTitle)\\\"\", preferredStyle: .Alert)\n  let okAction = UIAlertAction(title: \"OK\", style: .Default, handler: nil)\n  alertController.addAction(okAction)\n  \n  // Display an alert indicating the shortcut selected from the home screen.\n  window!.rootViewController?.presentViewController(alertController, animated: true, completion: nil)\n \n  return handled\n}\n```\n\nAnd finally we need call this method in the next \u003ci\u003eAppDelegate\u003c/i\u003e situations:\n\n```swift\nfunc application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: Bool -\u003e Void) {\n  let handledShortCutItem = handleShortCutItem(shortcutItem)\n  completionHandler(handledShortCutItem)\n}\n```\n\nAnd in \u003ci\u003eapplicationDidBecomeActive\u003c/i\u003e:\n\n```swift\nfunc applicationDidBecomeActive(application: UIApplication) {\n  guard let shortcut = launchedShortcutItem else { return }\n  handleShortCutItem(shortcut)\n  launchedShortcutItem = nil\n}\n```\n\nThat’s all. How to work with dynamic items, you can check an official \u003ci\u003eApple\u003c/i\u003e example, there is not present any difficulties.\n\n\u003cb\u003eNOTE:\u003c/b\u003e If you don’t have real \u003ci\u003eiPhone 6\u003c/i\u003e or \u003ci\u003eiPhone 6 Plus\u003c/i\u003e, you can test on a simulator with helping \u003ca href=\"https://github.com/DeskConnect/SBShortcutMenuSimulator\"\u003ethis\u003c/a\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximbilan%2F3d-touch-quick-actions-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaximbilan%2F3d-touch-quick-actions-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximbilan%2F3d-touch-quick-actions-demo/lists"}