├── .gitignore ├── LICENSE ├── README.md ├── ShortcutsDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── xcshareddata │ └── IDEWorkspaceChecks.plist └── ShortcutsDemo ├── AppDelegate.swift ├── Assets.xcassets ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Extensions.swift ├── Info.plist ├── MoreInfoViewController.swift └── ViewController.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | # Package.resolved 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | 51 | # Carthage 52 | # 53 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 54 | # Carthage/Checkouts 55 | 56 | Carthage/Build 57 | 58 | # fastlane 59 | # 60 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 61 | # screenshots whenever they are needed. 62 | # For more information about the recommended setup visit: 63 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 64 | 65 | fastlane/report.xml 66 | fastlane/Preview.html 67 | fastlane/screenshots/**/*.png 68 | fastlane/test_output 69 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Alessio Roberto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ShortcutsDemo 2 | 3 | Inspired by Paul Hudson's article [What’s new in iOS 12?](https://www.hackingwithswift.com/articles/121/whats-new-in-ios-12), 4 | this simple demo shows how to handle two **Siri Shortcuts**. 5 | 6 | Enjoy! 7 | 8 | ## 📹 In Action 9 | 10 | A [video](https://vimeo.com/273785916) that shows how I can interact with the application using Siri Shortcuts 😎 11 | -------------------------------------------------------------------------------- /ShortcutsDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D90BC18F20C8801000586665 /* MoreInfoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D90BC18E20C8801000586665 /* MoreInfoViewController.swift */; }; 11 | D90BC19120C8828900586665 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D90BC19020C8828900586665 /* Extensions.swift */; }; 12 | D979D09D20C876EE004B69EA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D979D09C20C876EE004B69EA /* AppDelegate.swift */; }; 13 | D979D09F20C876EE004B69EA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D979D09E20C876EE004B69EA /* ViewController.swift */; }; 14 | D979D0A220C876EE004B69EA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D979D0A020C876EE004B69EA /* Main.storyboard */; }; 15 | D979D0A420C876EF004B69EA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D979D0A320C876EF004B69EA /* Assets.xcassets */; }; 16 | D979D0A720C876EF004B69EA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D979D0A520C876EF004B69EA /* LaunchScreen.storyboard */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | D90BC18E20C8801000586665 /* MoreInfoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoreInfoViewController.swift; sourceTree = ""; }; 21 | D90BC19020C8828900586665 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; }; 22 | D979D09920C876EE004B69EA /* ShortcutsDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ShortcutsDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | D979D09C20C876EE004B69EA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 24 | D979D09E20C876EE004B69EA /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 25 | D979D0A120C876EE004B69EA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | D979D0A320C876EF004B69EA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | D979D0A620C876EF004B69EA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | D979D0A820C876EF004B69EA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | D979D09620C876EE004B69EA /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | D979D09020C876EE004B69EA = { 43 | isa = PBXGroup; 44 | children = ( 45 | D979D09B20C876EE004B69EA /* ShortcutsDemo */, 46 | D979D09A20C876EE004B69EA /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | D979D09A20C876EE004B69EA /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | D979D09920C876EE004B69EA /* ShortcutsDemo.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | D979D09B20C876EE004B69EA /* ShortcutsDemo */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | D979D0A820C876EF004B69EA /* Info.plist */, 62 | D979D09C20C876EE004B69EA /* AppDelegate.swift */, 63 | D90BC19020C8828900586665 /* Extensions.swift */, 64 | D90BC18E20C8801000586665 /* MoreInfoViewController.swift */, 65 | D979D09E20C876EE004B69EA /* ViewController.swift */, 66 | D979D0A320C876EF004B69EA /* Assets.xcassets */, 67 | D979D0A520C876EF004B69EA /* LaunchScreen.storyboard */, 68 | D979D0A020C876EE004B69EA /* Main.storyboard */, 69 | ); 70 | path = ShortcutsDemo; 71 | sourceTree = ""; 72 | }; 73 | /* End PBXGroup section */ 74 | 75 | /* Begin PBXNativeTarget section */ 76 | D979D09820C876EE004B69EA /* ShortcutsDemo */ = { 77 | isa = PBXNativeTarget; 78 | buildConfigurationList = D979D0AB20C876EF004B69EA /* Build configuration list for PBXNativeTarget "ShortcutsDemo" */; 79 | buildPhases = ( 80 | D979D09520C876EE004B69EA /* Sources */, 81 | D979D09620C876EE004B69EA /* Frameworks */, 82 | D979D09720C876EE004B69EA /* Resources */, 83 | ); 84 | buildRules = ( 85 | ); 86 | dependencies = ( 87 | ); 88 | name = ShortcutsDemo; 89 | productName = ShortcutsDemo; 90 | productReference = D979D09920C876EE004B69EA /* ShortcutsDemo.app */; 91 | productType = "com.apple.product-type.application"; 92 | }; 93 | /* End PBXNativeTarget section */ 94 | 95 | /* Begin PBXProject section */ 96 | D979D09120C876EE004B69EA /* Project object */ = { 97 | isa = PBXProject; 98 | attributes = { 99 | LastSwiftUpdateCheck = 1000; 100 | LastUpgradeCheck = 1000; 101 | ORGANIZATIONNAME = "Alessio Roberto"; 102 | TargetAttributes = { 103 | D979D09820C876EE004B69EA = { 104 | CreatedOnToolsVersion = 10.0; 105 | }; 106 | }; 107 | }; 108 | buildConfigurationList = D979D09420C876EE004B69EA /* Build configuration list for PBXProject "ShortcutsDemo" */; 109 | compatibilityVersion = "Xcode 9.3"; 110 | developmentRegion = en; 111 | hasScannedForEncodings = 0; 112 | knownRegions = ( 113 | en, 114 | Base, 115 | ); 116 | mainGroup = D979D09020C876EE004B69EA; 117 | productRefGroup = D979D09A20C876EE004B69EA /* Products */; 118 | projectDirPath = ""; 119 | projectRoot = ""; 120 | targets = ( 121 | D979D09820C876EE004B69EA /* ShortcutsDemo */, 122 | ); 123 | }; 124 | /* End PBXProject section */ 125 | 126 | /* Begin PBXResourcesBuildPhase section */ 127 | D979D09720C876EE004B69EA /* Resources */ = { 128 | isa = PBXResourcesBuildPhase; 129 | buildActionMask = 2147483647; 130 | files = ( 131 | D979D0A720C876EF004B69EA /* LaunchScreen.storyboard in Resources */, 132 | D979D0A420C876EF004B69EA /* Assets.xcassets in Resources */, 133 | D979D0A220C876EE004B69EA /* Main.storyboard in Resources */, 134 | ); 135 | runOnlyForDeploymentPostprocessing = 0; 136 | }; 137 | /* End PBXResourcesBuildPhase section */ 138 | 139 | /* Begin PBXSourcesBuildPhase section */ 140 | D979D09520C876EE004B69EA /* Sources */ = { 141 | isa = PBXSourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | D90BC18F20C8801000586665 /* MoreInfoViewController.swift in Sources */, 145 | D979D09F20C876EE004B69EA /* ViewController.swift in Sources */, 146 | D979D09D20C876EE004B69EA /* AppDelegate.swift in Sources */, 147 | D90BC19120C8828900586665 /* Extensions.swift in Sources */, 148 | ); 149 | runOnlyForDeploymentPostprocessing = 0; 150 | }; 151 | /* End PBXSourcesBuildPhase section */ 152 | 153 | /* Begin PBXVariantGroup section */ 154 | D979D0A020C876EE004B69EA /* Main.storyboard */ = { 155 | isa = PBXVariantGroup; 156 | children = ( 157 | D979D0A120C876EE004B69EA /* Base */, 158 | ); 159 | name = Main.storyboard; 160 | sourceTree = ""; 161 | }; 162 | D979D0A520C876EF004B69EA /* LaunchScreen.storyboard */ = { 163 | isa = PBXVariantGroup; 164 | children = ( 165 | D979D0A620C876EF004B69EA /* Base */, 166 | ); 167 | name = LaunchScreen.storyboard; 168 | sourceTree = ""; 169 | }; 170 | /* End PBXVariantGroup section */ 171 | 172 | /* Begin XCBuildConfiguration section */ 173 | D979D0A920C876EF004B69EA /* Debug */ = { 174 | isa = XCBuildConfiguration; 175 | buildSettings = { 176 | ALWAYS_SEARCH_USER_PATHS = NO; 177 | CLANG_ANALYZER_NONNULL = YES; 178 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 179 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 180 | CLANG_CXX_LIBRARY = "libc++"; 181 | CLANG_ENABLE_MODULES = YES; 182 | CLANG_ENABLE_OBJC_ARC = YES; 183 | CLANG_ENABLE_OBJC_WEAK = YES; 184 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 185 | CLANG_WARN_BOOL_CONVERSION = YES; 186 | CLANG_WARN_COMMA = YES; 187 | CLANG_WARN_CONSTANT_CONVERSION = YES; 188 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 189 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 190 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 191 | CLANG_WARN_EMPTY_BODY = YES; 192 | CLANG_WARN_ENUM_CONVERSION = YES; 193 | CLANG_WARN_INFINITE_RECURSION = YES; 194 | CLANG_WARN_INT_CONVERSION = YES; 195 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 196 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 197 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 198 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 199 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 200 | CLANG_WARN_STRICT_PROTOTYPES = YES; 201 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 202 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 203 | CLANG_WARN_UNREACHABLE_CODE = YES; 204 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 205 | CODE_SIGN_IDENTITY = "iPhone Developer"; 206 | COPY_PHASE_STRIP = NO; 207 | DEBUG_INFORMATION_FORMAT = dwarf; 208 | ENABLE_STRICT_OBJC_MSGSEND = YES; 209 | ENABLE_TESTABILITY = YES; 210 | GCC_C_LANGUAGE_STANDARD = gnu11; 211 | GCC_DYNAMIC_NO_PIC = NO; 212 | GCC_NO_COMMON_BLOCKS = YES; 213 | GCC_OPTIMIZATION_LEVEL = 0; 214 | GCC_PREPROCESSOR_DEFINITIONS = ( 215 | "DEBUG=1", 216 | "$(inherited)", 217 | ); 218 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 219 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 220 | GCC_WARN_UNDECLARED_SELECTOR = YES; 221 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 222 | GCC_WARN_UNUSED_FUNCTION = YES; 223 | GCC_WARN_UNUSED_VARIABLE = YES; 224 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 225 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 226 | ONLY_ACTIVE_ARCH = YES; 227 | SDKROOT = iphoneos; 228 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 229 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 230 | }; 231 | name = Debug; 232 | }; 233 | D979D0AA20C876EF004B69EA /* Release */ = { 234 | isa = XCBuildConfiguration; 235 | buildSettings = { 236 | ALWAYS_SEARCH_USER_PATHS = NO; 237 | CLANG_ANALYZER_NONNULL = YES; 238 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_ENABLE_OBJC_WEAK = YES; 244 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 245 | CLANG_WARN_BOOL_CONVERSION = YES; 246 | CLANG_WARN_COMMA = YES; 247 | CLANG_WARN_CONSTANT_CONVERSION = YES; 248 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 249 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 250 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 251 | CLANG_WARN_EMPTY_BODY = YES; 252 | CLANG_WARN_ENUM_CONVERSION = YES; 253 | CLANG_WARN_INFINITE_RECURSION = YES; 254 | CLANG_WARN_INT_CONVERSION = YES; 255 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 257 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 258 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 259 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 260 | CLANG_WARN_STRICT_PROTOTYPES = YES; 261 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 262 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 263 | CLANG_WARN_UNREACHABLE_CODE = YES; 264 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 265 | CODE_SIGN_IDENTITY = "iPhone Developer"; 266 | COPY_PHASE_STRIP = NO; 267 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 268 | ENABLE_NS_ASSERTIONS = NO; 269 | ENABLE_STRICT_OBJC_MSGSEND = YES; 270 | GCC_C_LANGUAGE_STANDARD = gnu11; 271 | GCC_NO_COMMON_BLOCKS = YES; 272 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 273 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 274 | GCC_WARN_UNDECLARED_SELECTOR = YES; 275 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 276 | GCC_WARN_UNUSED_FUNCTION = YES; 277 | GCC_WARN_UNUSED_VARIABLE = YES; 278 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 279 | MTL_ENABLE_DEBUG_INFO = NO; 280 | SDKROOT = iphoneos; 281 | SWIFT_COMPILATION_MODE = wholemodule; 282 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 283 | VALIDATE_PRODUCT = YES; 284 | }; 285 | name = Release; 286 | }; 287 | D979D0AC20C876EF004B69EA /* Debug */ = { 288 | isa = XCBuildConfiguration; 289 | buildSettings = { 290 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 291 | CODE_SIGN_IDENTITY = "iPhone Developer"; 292 | CODE_SIGN_STYLE = Manual; 293 | DEVELOPMENT_TEAM = GK5S624D99; 294 | INFOPLIST_FILE = ShortcutsDemo/Info.plist; 295 | LD_RUNPATH_SEARCH_PATHS = ( 296 | "$(inherited)", 297 | "@executable_path/Frameworks", 298 | ); 299 | PRODUCT_BUNDLE_IDENTIFIER = com.alessioroberto.demo.ShortcutsDemo; 300 | PRODUCT_NAME = "$(TARGET_NAME)"; 301 | PROVISIONING_PROFILE = "db1d5e59-6fb3-49ea-b5f3-b045b305bc5f"; 302 | PROVISIONING_PROFILE_SPECIFIER = "Demo Development"; 303 | SWIFT_VERSION = 4.2; 304 | TARGETED_DEVICE_FAMILY = "1,2"; 305 | }; 306 | name = Debug; 307 | }; 308 | D979D0AD20C876EF004B69EA /* Release */ = { 309 | isa = XCBuildConfiguration; 310 | buildSettings = { 311 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 312 | CODE_SIGN_IDENTITY = "iPhone Developer"; 313 | CODE_SIGN_STYLE = Manual; 314 | DEVELOPMENT_TEAM = ""; 315 | INFOPLIST_FILE = ShortcutsDemo/Info.plist; 316 | LD_RUNPATH_SEARCH_PATHS = ( 317 | "$(inherited)", 318 | "@executable_path/Frameworks", 319 | ); 320 | PRODUCT_BUNDLE_IDENTIFIER = com.alessioroberto.demo.ShortcutsDemo; 321 | PRODUCT_NAME = "$(TARGET_NAME)"; 322 | PROVISIONING_PROFILE_SPECIFIER = ""; 323 | SWIFT_VERSION = 4.2; 324 | TARGETED_DEVICE_FAMILY = "1,2"; 325 | }; 326 | name = Release; 327 | }; 328 | /* End XCBuildConfiguration section */ 329 | 330 | /* Begin XCConfigurationList section */ 331 | D979D09420C876EE004B69EA /* Build configuration list for PBXProject "ShortcutsDemo" */ = { 332 | isa = XCConfigurationList; 333 | buildConfigurations = ( 334 | D979D0A920C876EF004B69EA /* Debug */, 335 | D979D0AA20C876EF004B69EA /* Release */, 336 | ); 337 | defaultConfigurationIsVisible = 0; 338 | defaultConfigurationName = Release; 339 | }; 340 | D979D0AB20C876EF004B69EA /* Build configuration list for PBXNativeTarget "ShortcutsDemo" */ = { 341 | isa = XCConfigurationList; 342 | buildConfigurations = ( 343 | D979D0AC20C876EF004B69EA /* Debug */, 344 | D979D0AD20C876EF004B69EA /* Release */, 345 | ); 346 | defaultConfigurationIsVisible = 0; 347 | defaultConfigurationName = Release; 348 | }; 349 | /* End XCConfigurationList section */ 350 | }; 351 | rootObject = D979D09120C876EE004B69EA /* Project object */; 352 | } 353 | -------------------------------------------------------------------------------- /ShortcutsDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ShortcutsDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ShortcutsDemo 4 | // 5 | // Created by Alessio Roberto on 06/06/2018. 6 | // Copyright © 2018 Alessio Roberto. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { 23 | if userActivity.activityType == "com.alessioroberto.example.showinfo" { 24 | print("Show info...") 25 | UserDefaults.standard.actionState = "com.alessioroberto.example.showinfo" 26 | } else if userActivity.activityType == "com.alessioroberto.example.showmoreinfo" { 27 | print("Show more info...") 28 | UserDefaults.standard.actionState = "com.alessioroberto.example.showmoreinfo" 29 | } 30 | return true 31 | } 32 | 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /ShortcutsDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /ShortcutsDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ShortcutsDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ShortcutsDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 29 | 30 | 31 | 32 | Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. 33 | 34 | 35 | 36 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 83 | 84 | 85 | 86 | 92 | 98 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /ShortcutsDemo/Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Extensions.swift 3 | // ShortcutsDemo 4 | // 5 | // Created by Alessio Roberto on 06/06/2018. 6 | // Copyright © 2018 Alessio Roberto. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension UserDefaults { 12 | var actionState: String? { 13 | get { return string(forKey: #function) } 14 | set { set(newValue, forKey: #function) } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ShortcutsDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | NSUserActivityTypes 45 | 46 | com.alessioroberto.example.showinfo 47 | com.alessioroberto.example.showmoreinfo 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /ShortcutsDemo/MoreInfoViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MoreInfoViewController.swift 3 | // ShortcutsDemo 4 | // 5 | // Created by Alessio Roberto on 06/06/2018. 6 | // Copyright © 2018 Alessio Roberto. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MoreInfoViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | // Do any additional setup after loading the view. 17 | } 18 | 19 | override func viewDidAppear(_ animated: Bool) { 20 | super.viewDidAppear(animated) 21 | 22 | activitySetup() 23 | } 24 | 25 | private func activitySetup() { 26 | // give our activity a unique ID 27 | let activity = NSUserActivity(activityType: "com.alessioroberto.example.showmoreinfo") 28 | 29 | // give it a title that will be displayed to users 30 | activity.title = "Show more info" 31 | 32 | // allow Siri to index this and use it for voice-matched queries 33 | activity.isEligibleForSearch = true 34 | activity.isEligibleForPrediction = true 35 | 36 | // attach some example information that we can use when loading the app from this activity 37 | activity.userInfo = ["message": "There're more info!"] 38 | 39 | // give the activity a unique identifier so we can delete it later if we need to 40 | activity.persistentIdentifier = NSUserActivityPersistentIdentifier("def") 41 | 42 | // make this activity active for the current view controller – this is what Siri will restore when the activity is triggered 43 | self.userActivity = activity 44 | } 45 | 46 | @IBAction func closeButtonTapped(_ sender: Any) { 47 | self.dismiss(animated: true, completion: nil) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ShortcutsDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ShortcutsDemo 4 | // 5 | // Created by Alessio Roberto on 06/06/2018. 6 | // Copyright © 2018 Alessio Roberto. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class ViewController: UIViewController { 13 | lazy var notificationCenter: NotificationCenter = { 14 | NotificationCenter.default 15 | }() 16 | 17 | deinit { 18 | notificationCenter.removeObserver(self) 19 | } 20 | 21 | override func viewDidLoad() { 22 | super.viewDidLoad() 23 | // Do any additional setup after loading the view, typically from a nib. 24 | } 25 | 26 | override func viewDidAppear(_ animated: Bool) { 27 | super.viewDidAppear(animated) 28 | 29 | activitySetup() 30 | } 31 | 32 | override func viewWillAppear(_ animated: Bool) { 33 | super.viewWillAppear(animated) 34 | 35 | notificationCenter.addObserver(self, 36 | selector: #selector(ViewController.enterForegroundOperation), 37 | name: UIApplication.didBecomeActiveNotification, 38 | object: nil) 39 | } 40 | 41 | @objc func enterForegroundOperation() { 42 | if let action = UserDefaults.standard.actionState { 43 | if action == "com.alessioroberto.example.showmoreinfo" { 44 | self.performSegue(withIdentifier: "ShowMoreInfo", sender: self) 45 | } 46 | // Reset state 47 | UserDefaults.standard.actionState = nil 48 | } 49 | } 50 | 51 | private func activitySetup() { 52 | // give our activity a unique ID 53 | let activity = NSUserActivity(activityType: "com.alessioroberto.example.showinfo") 54 | 55 | // give it a title that will be displayed to users 56 | activity.title = "Show the latest info" 57 | 58 | // allow Siri to index this and use it for voice-matched queries 59 | activity.isEligibleForSearch = true 60 | activity.isEligibleForPrediction = true 61 | 62 | // attach some example information that we can use when loading the app from this activity 63 | activity.userInfo = ["message": "Important last info!"] 64 | 65 | // give the activity a unique identifier so we can delete it later if we need to 66 | activity.persistentIdentifier = NSUserActivityPersistentIdentifier("abc") 67 | 68 | // make this activity active for the current view controller – this is what Siri will restore when the activity is triggered 69 | self.userActivity = activity 70 | } 71 | } 72 | 73 | --------------------------------------------------------------------------------