{"id":1230,"url":"https://github.com/ricardopereira/QuickActions","last_synced_at":"2025-07-30T20:32:54.786Z","repository":{"id":62451686,"uuid":"52401723","full_name":"ricardopereira/QuickActions","owner":"ricardopereira","description":"Swift wrapper for iOS Home Screen Quick Actions (App Icon Shortcuts)","archived":false,"fork":false,"pushed_at":"2023-10-12T15:50:09.000Z","size":68,"stargazers_count":254,"open_issues_count":3,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-07T08:43:30.318Z","etag":null,"topics":["force-touch","ios","quickactions","shortcuts"],"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/ricardopereira.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}},"created_at":"2016-02-24T00:24:09.000Z","updated_at":"2024-10-02T23:50:38.000Z","dependencies_parsed_at":"2024-01-02T21:08:29.601Z","dependency_job_id":null,"html_url":"https://github.com/ricardopereira/QuickActions","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricardopereira%2FQuickActions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricardopereira%2FQuickActions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricardopereira%2FQuickActions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricardopereira%2FQuickActions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ricardopereira","download_url":"https://codeload.github.com/ricardopereira/QuickActions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228187588,"owners_count":17882329,"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":["force-touch","ios","quickactions","shortcuts"],"created_at":"2024-01-05T20:15:41.778Z","updated_at":"2024-12-04T20:31:07.838Z","avatar_url":"https://github.com/ricardopereira.png","language":"Swift","funding_links":[],"categories":["Hardware","Swift"],"sub_categories":["Force Touch","Other free courses"],"readme":"[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/QuickActions.svg)](https://cocoapods.org/pods/QuickActions)\n[![Swift 5.0](https://img.shields.io/badge/Swift-5.0-orange.svg?style=flat)](https://developer.apple.com/swift/)\n[![Platforms iOS](https://img.shields.io/badge/Platforms-iOS-lightgray.svg?style=flat)](http://www.apple.com/ios/)\n[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n\n# QuickActions\nSwift wrapper for [iOS Home Screen Quick Actions](https://developer.apple.com/library/prerelease/ios/documentation/UserExperience/Conceptual/Adopting3DTouchOniPhone/index.html#//apple_ref/doc/uid/TP40016543-CH1-SW2)\n\nThis wrapper helps you create dynamic Quick Actions. It is possible to define static quick actions in your app’s `Info.plist` file and also add localizable shortcuts dynamically and handle them with type safety.\n\n## Usage\n\n```swift\nimport QuickActions\n```\n\nDefine your application shortcuts with an enum. Don't forget to declare the enum with `String` and `ShortcutType`:\n\n```swift\nenum AppShortcut: String, ShortcutType {\n    case createExpense\n    case lastItems\n}\n```\n\nInstall a list of shortcuts:\n\n\n```swift\nvar quickActions: QuickActions\u003cAppShortcut\u003e?\n\nfunc application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -\u003e Bool {\n    let shortcuts = [Shortcut(type: AppShortcut.CreateExpense, title: NSLocalizedString(\"CreateExpenseTitle\", comment: \"\"), subtitle: NSLocalizedString(\"CreateExpenseSubTitle\", comment: \"\"), icon: .Add)]\n\n    if let actionHandler = window?.rootViewController as? QuickActionSupport, bundleIdentifier = Bundle.main.bundleIdentifier {\n        quickActions = QuickActions(application, actionHandler: actionHandler, bundleIdentifier: bundleIdentifier, shortcuts: shortcuts, launchOptions: launchOptions)\n    }\n}\n```\n\nAdd more shortcuts:\n\n```swift\nfunc applicationDidEnterBackground(application: UIApplication) {\n    let shortcuts = [Shortcut(type: AppShortcut.lastItems, title: \"Last items\", subtitle: nil, icon: nil)]\n    quickActions?.add(shortcuts, toApplication: application)\n}\n```\n\nHandle each shortcut:\n\n```swift\n@available(iOS 9, *)\nfunc application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -\u003e Swift.Void) {\n    // This callback is used if your application is already launched in the background, if not application(_:,willFinishLaunchingWithOptions:) or application(_:didFinishLaunchingWithOptions) will be called (handle the shortcut in those callbacks and return `false`)\n    guard let quickActions = quickActions else {\n        return completionHandler(false)\n    }\n    guard let actionHandler = window?.rootViewController as? QuickActionSupport else {\n        return completionHandler(false)\n    }\n    completionHandler(quickActions.handle(actionHandler, shortcutItem: shortcutItem))\n}\n```\n\nPrepare your view controller using the `QuickActionSupport` protocol:\n\n```swift\nclass MainViewController: UIViewController, QuickActionSupport {\n\n    func prepareForQuickAction\u003cT: ShortcutType\u003e(_ shortcutType: T) {\n        if let shortcut = AppShortcut(rawValue: shortcutType.value), case .createExpense = shortcut {\n            print(\"Prepare the view to create a new expense\")\n        }\n\n        //or\n\n        if let shortcut = AppShortcut(rawValue: shortcutType.value) {\n            switch shortcut {\n            case .createExpense:\n                print(\"Prepare the view to create a new expense\")\n            case .lastItems:\n                print(\"Prepare the view to show last items\")\n            }\n        }\n    }    \n\n}\n```\n\n## Installation\n\n#### \u003cimg src=\"https://raw.githubusercontent.com/ricardopereira/resources/master/img/cocoapods.png\" width=\"24\" height=\"24\"\u003e [CocoaPods]\n\n[CocoaPods]: http://cocoapods.org\n\nTo install it, simply add the following line to your **Podfile**:\n\n```ruby\npod 'QuickActions' '~\u003e 6.0.0'\n```\n\nYou will also need to make sure you're opting into using frameworks:\n\n```ruby\nuse_frameworks!\n```\n\nThen run `pod install` with CocoaPods 1.8.0 or newer.\n\n#### Manually\n1. Download and drop ```QuickActions.swift``` in your project.  \n2. Congratulations! \n\n## Requirements\n\n* iOS 12+\n* Xcode 13+ (Swift 5)\n\n## Author\n\nRicardo Pereira, [@ricardopereiraw](https://mastodon.social/@ricardopereira)\n\n## License\n\nQuickActions is available under the MIT license. See the [LICENSE] file for more info.\n\n[LICENSE]: /LICENSE\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fricardopereira%2FQuickActions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fricardopereira%2FQuickActions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fricardopereira%2FQuickActions/lists"}