{"id":33738,"date":"2016-04-19T17:00:58","date_gmt":"2016-04-19T11:30:58","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=33738"},"modified":"2016-04-19T17:00:58","modified_gmt":"2016-04-19T11:30:58","slug":"quick-action-3d-touch","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/quick-action-3d-touch\/","title":{"rendered":"Quick Action-3D touch"},"content":{"rendered":"<p>In this blog, we will be discussing about <strong>Quick Action<\/strong> (Another feature provided by Apple in iOS 9.0 and above)<\/p>\n<p>To learn about peek and pop, you can refer my previous blog: <a href=\"http:\/\/www.tothenew.com\/blog\/playing-with-3d-touch-ios\/\">http:\/\/www.tothenew.com\/blog\/playing-with-3d-touch-ios\/<\/a><\/p>\n<h2><strong style=\"font-size: 1.285714286rem\">QUICK ACTIONS<\/strong><\/h2>\n<p><em>Home screen quick actions<\/em> give us a convenient way to perform useful, app-specific actions directly from the Home screen without entering inside the app.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-33739 aligncenter\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/04\/1.png\" alt=\"Camera Home Screen Quick Action\" width=\"270\" height=\"384\" \/><\/p>\n<p style=\"text-align: center\"><strong>Camera Home Screen Quick Action<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-33740 aligncenter\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/04\/2.png\" alt=\"Custom Home screen Quick Action\" width=\"270\" height=\"384\" \/><\/p>\n<p style=\"text-align: center\"><strong>Custom Home screen Quick Action\u00a0<\/strong><\/p>\n<p style=\"text-align: left\">iOS9 supports, <em>static<\/em> and <em>dynamic<\/em> quick actions.<\/p>\n<ul>\n<li><strong>Static quick actions<\/strong> are available to the user immediately upon app installation. Define Home screen static quick actions in your app\u2019s Info.plist file in the <a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/General\/Reference\/InfoPlistKeyReference\/Articles\/iPhoneOSKeys.html#\/\/apple_ref\/doc\/uid\/TP40009252-SW36\">UIApplicationShortcutItems<\/a> array.<\/li>\n<li><strong>Dynamic quick actions<\/strong> are available to the user after first launch. Define Home screen dynamic quick actions with the <a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/UIKit\/Reference\/UIApplicationShortcutItem_class\/index.html#\/\/apple_ref\/occ\/cl\/UIApplicationShortcutItem\">UIApplicationShortcutItem<\/a>, <a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/UIKit\/Reference\/UIMutableApplicationShortcutItem_class\/index.html#\/\/apple_ref\/occ\/cl\/UIMutableApplicationShortcutItem\">UIMutableApplicationShortcutItem<\/a>, and <a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/UIKit\/Reference\/UIApplicationShortcutIcon_Class\/index.html#\/\/apple_ref\/occ\/cl\/UIApplicationShortcutIcon\">UIApplicationShortcutIcon<\/a> Add dynamic quick actions to your app\u2019s shared <a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/UIKit\/Reference\/UIApplication_Class\/index.html#\/\/apple_ref\/occ\/cl\/UIApplication\">UIApplication<\/a> object using the <a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/UIKit\/Reference\/UIApplication_Class\/index.html#\/\/apple_ref\/occ\/instp\/UIApplication\/shortcutItems\">shortcutItems<\/a> property.<\/li>\n<\/ul>\n<h3><strong>Steps for static quick action Implementation:<\/strong><\/h3>\n<ol>\n<li>Open info.plist in your project<\/li>\n<li>Open it as source code of the plist file and add below code:<\/li>\n<\/ol>\n<p><code> &lt;key&gt;UIApplicationShortcutItems&lt;\/key&gt;<br \/>\n&lt;array&gt;<br \/>\n&lt;dict&gt;<br \/>\n&lt;key&gt;UIApplicationShortcutItemIconType&lt;\/key&gt;<br \/>\n&lt;string&gt;UIApplicationShortcutIconTypeSearch&lt;\/string&gt;<br \/>\n&lt;key&gt;UIApplicationShortcutItemTitle&lt;\/key&gt;<br \/>\n&lt;string&gt;SEARCH&lt;\/string&gt;<br \/>\n&lt;key&gt;UIApplicationShortcutItemType&lt;\/key&gt;<br \/>\n&lt;string&gt;$(PRODUCT_BUNDLE_IDENTIFIER).Search&lt;\/string&gt;<br \/>\n&lt;\/dict&gt;<br \/>\n&lt;dict&gt;<br \/>\n&lt;key&gt;UIApplicationShortcutItemTitle&lt;\/key&gt;<br \/>\n&lt;string&gt;FAVORITES&lt;\/string&gt;<br \/>\n&lt;key&gt;UIApplicationShortcutItemType&lt;\/key&gt;<br \/>\n&lt;string&gt;$(PRODUCT_BUNDLE_IDENTIFIER).Favorites&lt;\/string&gt;<br \/>\n&lt;key&gt;UIApplicationShortcutItemIconFile&lt;\/key&gt;<br \/>\n&lt;string&gt;ShortcutIconFavorites&lt;\/string&gt;<br \/>\n&lt;\/dict&gt;<br \/>\n&lt;\/array&gt;<\/code><\/p>\n<p>The above code provides us with some keys that are needed to add quick action.<\/p>\n<p>The required keys are :<\/p>\n<ul>\n<li><strong>UIApplicationShortcutItemType<\/strong> : A string that is sent as a part of UIApplicationShortcutItem. It can be used in code for handling different actions.<\/li>\n<li><strong>UIApplicationShortcutItemTitle<\/strong> : This is the title that will be displayed on quick action menu.<\/li>\n<\/ul>\n<p>The optional keys are:<\/p>\n<ul>\n<li><strong>UIApplicationShortcutItemSubtitle<\/strong>:\u00a0An optional key that describes the subtitle of your action displayed under the title.<\/li>\n<li><strong>UIApplicationShortcutItemIconType<\/strong>: An optional string which define built in action type<\/li>\n<\/ul>\n<p>To check the list of built-in icons go through the following link:<\/p>\n<p><a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/UIKit\/Reference\/UIApplicationShortcutIcon_Class\/index.html#\/\/apple_ref\/c\/tdef\/UIApplicationShortcutIconType\">https:\/\/developer.apple.com\/library\/ios\/documentation\/UIKit\/Reference\/UIApplicationShortcutIcon_Class\/index.html#\/\/apple_ref\/c\/tdef\/UIApplicationShortcutIconType<\/a><\/p>\n<ul>\n<li><strong>UIApplicationShortcutItemIconFile<\/strong>\u200a\u2014\u200aan optional string specifying an image from Assets Catalog or from the Bundle. More information on image sizes and design guidelines can be found <a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/UserExperience\/Conceptual\/MobileHIG\/index.html#\/\/apple_ref\/doc\/uid\/TP40006556-CH66-SW1\">here<\/a>. If this key is specified, then the system ignores UIApplicationShortcutItemIconType;<\/li>\n<li><strong>UIApplicationShortcutItemUserInfo<\/strong>\u200a\u2014\u200aan optional dictionary of additional information which you may want to parse.<\/li>\n<\/ul>\n<h3><strong>Steps for dynamic quick action implementation:<\/strong><\/h3>\n<ol>\n<li>Open initial viewController and add following code in <strong>viewDidLoad()<\/strong>:<\/li>\n<\/ol>\n<p><span style=\"font-family: Consolas, Monaco, 'Lucida Console', monospace;font-size: 0.857142857rem\">let DeleteShortcut= UIApplicationShortcutItem(type: &#8221; com.ttndevelopment.quickAction&#8221;, localizedTitle: &#8220;Delete item&#8221;, localizedSubtitle: &#8220;Dynamic Action&#8221;, icon: UIApplicationShortcutIcon(type: .Delete), userInfo: nil)<\/span><\/p>\n<p><code>UIApplication.sharedApplication().shortcutItems = [DeleteShortcut]<\/code><\/p>\n<p><strong>Provide an appropriate action for them.<\/strong><\/p>\n<p>We should always keep in mind that there are two different situations:<\/p>\n<ul>\n<li>The application is closed and the user opens the application via quick action shortcut. In this case application:didFinishLaunchingWithOptions: will be called. launchingOptions will contain UIApplicationShortcutItem stored on\u00a0key\u00a0<em>UIApplicationLaunchOptionsShortcutItemKey<\/em>;<\/li>\n<li>The application was opened before and the user wants to continue usage with a shortcut. In this case the application will call this AppDelegate<\/li>\n<\/ul>\n<p><span style=\"font-family: Consolas, Monaco, 'Lucida Console', monospace;font-size: 0.857142857rem\">func application(application: UIApplication,\u00a0performActionForShortcutItem shortcutItem: UIApplicationShortcutItem,completionHandler: (Bool) -&gt; Void) {<\/span><span style=\"font-family: Consolas, Monaco, 'Lucida Console', monospace;font-size: 0.857142857rem\">print(&#8220;Shortcut tapped&#8221;)<\/span><span style=\"font-family: Consolas, Monaco, 'Lucida Console', monospace;font-size: 0.857142857rem\">}<\/span><\/p>\n<h3>\u00a0<strong>Conclusion:<\/strong><\/h3>\n<ol>\n<li>It gives us quick access to everything.<\/li>\n<li>We can enter directly to various controllers where we want to perform some or other actions.<\/li>\n<li>We can peek into various things directly inspite of going for its details.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, we will be discussing about Quick Action (Another feature provided by Apple in iOS 9.0 and above) To learn about peek and pop, you can refer my previous blog: http:\/\/www.tothenew.com\/blog\/playing-with-3d-touch-ios\/ QUICK ACTIONS Home screen quick actions give us a convenient way to perform useful, app-specific actions directly from the Home screen without [&hellip;]<\/p>\n","protected":false},"author":514,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":7},"categories":[1400],"tags":[3170,3209,3207,3206,3208],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/33738"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/514"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=33738"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/33738\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=33738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=33738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=33738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}