{"id":7595,"date":"2020-10-26T18:40:50","date_gmt":"2020-10-26T17:40:50","guid":{"rendered":"https:\/\/www.creativejuiz.fr\/blog?p=7595"},"modified":"2020-10-26T18:41:49","modified_gmt":"2020-10-26T17:41:49","slug":"pwa-add-shortcuts-to-your-application","status":"publish","type":"post","link":"https:\/\/www.creativejuiz.fr\/blog\/en\/tutorials\/pwa-add-shortcuts-to-your-application","title":{"rendered":"PWA &#8211; Add shortcuts to your application"},"content":{"rendered":"<p>You have probably already used these shortcuts available at &#8220;force touch&#8221; or &#8220;long touch&#8221; on your mobile application icons? It&#8217;s a way to access shortcuts inside your application to quickly access a section, or directly start a more precise action. It is now possible to do this for your Progressive Web App (PWA).<\/p>\n<p><!--more--><\/p>\n<p class=\"message important\"><strong>Note:<\/strong> At the time of writing these lines, this feature is not yet functional on all browsers. Only the 86+ version of Chrome Android, and Edge seems to include this feature.<\/p>\n<h2>What do PWA Shortcuts look like?<\/h2>\n<p>PWA (Progressive Web App) Shortcuts, are a good way to provide quick access to a few well-defined features of your Progressive Web App.<br \/>\nI&#8217;ve been working on it recently for a small <a href=\"https:\/\/sharebuttons.social\">WordPress plugin website of share buttons<\/a> to do some testing. I&#8217;ve implemented 2 shortcuts which look like this, in image and video.<\/p>\n<p class=\"center\"><img decoding=\"async\" class=\"size-full wp-image-7580 alignnone\" style=\"margin-right: 8px; margin-left: 8px;\" src=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/wordpress-social-share-buttons-pwa.jpg\" alt=\"\" width=\"270\" height=\"585\" srcset=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/wordpress-social-share-buttons-pwa.jpg 1080w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/wordpress-social-share-buttons-pwa-138x300.jpg 138w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/wordpress-social-share-buttons-pwa-277x600.jpg 277w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/wordpress-social-share-buttons-pwa-768x1664.jpg 768w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/wordpress-social-share-buttons-pwa-709x1536.jpg 709w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/wordpress-social-share-buttons-pwa-945x2048.jpg 945w\" sizes=\"(max-width: 270px) 100vw, 270px\" \/> <img decoding=\"async\" class=\"size-full wp-image-7578 alignnone\" style=\"margin-right: 8px; margin-left: 8px;\" src=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/wordpress-social-share-buttons-pwa-shortcuts.jpg\" alt=\"\" width=\"270\" height=\"585\" srcset=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/wordpress-social-share-buttons-pwa-shortcuts.jpg 1080w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/wordpress-social-share-buttons-pwa-shortcuts-138x300.jpg 138w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/wordpress-social-share-buttons-pwa-shortcuts-277x600.jpg 277w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/wordpress-social-share-buttons-pwa-shortcuts-768x1664.jpg 768w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/wordpress-social-share-buttons-pwa-shortcuts-709x1536.jpg 709w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/wordpress-social-share-buttons-pwa-shortcuts-945x2048.jpg 945w\" sizes=\"(max-width: 270px) 100vw, 270px\" \/><\/p>\n<p>Here are two videos of PWA Shortcuts in their natural environment, one when you activate one of the shortcuts, the other shows you how PWA Shortcuts work like the native versions of applications: you can layout them on your phone&#8217;s homepage, and they can even have their own icons.<\/p>\n<div style=\"width: 295px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-7595-1\" width=\"295\" height=\"640\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-open-shortcut.mp4?_=1\" \/><a href=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-open-shortcut.mp4\">https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-open-shortcut.mp4<\/a><\/video><\/div>\n<div style=\"width: 295px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-7595-2\" width=\"295\" height=\"640\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-shortcuts-on-home.mp4?_=2\" \/><a href=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-shortcuts-on-home.mp4\">https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-shortcuts-on-home.mp4<\/a><\/video><\/div>\n<h2>How to create a PWA shortcut?<\/h2>\n<p>The creation of a shortcut for a Progressive Web App is done via the manifest.json (or site.webmanifest) file which already declares several essential elements for your web application, such as: the name of the application, its theme color, screenshots, the notion of <code>start_url<\/code>, etc.<\/p>\n<h3>Webmanifest to create a PWA Shortcut<\/h3>\n<p>In this list, it is therefore necessary to add the notion of shortcuts, if you feel the need for it for your users, of course.<\/p>\n<div class=\"code-embed-wrapper\"> <pre class=\"language-php code-embed-pre line-numbers\"  data-line=\"42-67\" data-start=\"1\" data-line-offset=\"0\"><code class=\"language-php code-embed-code\">{<br\/>    &quot;name&quot;: &quot;Nobs - Share Buttons&quot;,<br\/>    &quot;short_name&quot;: &quot;Nobs&quot;,<br\/>    &quot;icons&quot;: [<br\/>        {<br\/>            &quot;src&quot;: &quot;\/android-chrome-192x192.png&quot;,<br\/>            &quot;sizes&quot;: &quot;192x192&quot;,<br\/>            &quot;type&quot;: &quot;image\/png&quot;<br\/>        },<br\/>        {<br\/>            &quot;src&quot;: &quot;\/android-chrome-384x384.png&quot;,<br\/>            &quot;sizes&quot;: &quot;384x384&quot;,<br\/>            &quot;type&quot;: &quot;image\/png&quot;<br\/>        }<br\/>    ],<br\/>    &quot;theme_color&quot;: &quot;#067FA5&quot;,<br\/>    &quot;background_color&quot;: &quot;#ffffff&quot;,<br\/>    &quot;display&quot;: &quot;standalone&quot;,<br\/>    &quot;start_url&quot;: &quot;https:\/\/sharebuttons.social\/&quot;,<br\/>    &quot;url&quot; : &quot;https:\/\/sharebuttons.social&quot;,<br\/>    &quot;lang&quot;: &quot;English&quot;,<br\/>    &quot;screenshots&quot; : [<br\/>        {<br\/>            &quot;src&quot;: &quot;\/assets\/img\/screenshot-1.jpg&quot;,<br\/>            &quot;sizes&quot;: &quot;1280x800&quot;,<br\/>            &quot;type&quot;: &quot;image\/jpg&quot;<br\/>        },<br\/>        {<br\/>            &quot;src&quot;: &quot;\/assets\/img\/screenshot-2.jpg&quot;,<br\/>            &quot;sizes&quot;: &quot;1280x800&quot;,<br\/>            &quot;type&quot;: &quot;image\/jpg&quot;<br\/>        }<br\/>    ],<br\/>    &quot;categories&quot; : [<br\/>        &quot;navigation&quot;,<br\/>        &quot;lifestyle&quot;,<br\/>        &quot;personalization&quot;,<br\/>        &quot;productivity&quot;,<br\/>        &quot;social&quot;,<br\/>        &quot;utilities&quot;<br\/>    ],<br\/>    &quot;shortcuts&quot;: [<br\/>        {<br\/>            &quot;name&quot;: &quot;Features&quot;, <br\/>            &quot;description&quot;: &quot;A list of plugin features.&quot;,<br\/>            &quot;url&quot;: &quot;\/features.html&quot;,<br\/>            &quot;icons&quot;: [<br\/>                {<br\/>                    &quot;src&quot;: &quot;\/assets\/img\/picto-feat.png&quot;,<br\/>                    &quot;type&quot;: &quot;image\/png&quot;,<br\/>                    &quot;purpose&quot;: &quot;any&quot;<br\/>                }<br\/>            ]<br\/>        },<br\/>        {<br\/>            &quot;name&quot;: &quot;Pricing&quot;, <br\/>            &quot;description&quot;: &quot;The plugin offers&quot;,<br\/>            &quot;url&quot;: &quot;\/free-plugin.html&quot;,<br\/>            &quot;icons&quot;: [<br\/>                {<br\/>                    &quot;src&quot;: &quot;\/assets\/img\/picto-price.png&quot;,<br\/>                    &quot;type&quot;: &quot;image\/png&quot;,<br\/>                    &quot;purpose&quot;: &quot;any&quot;<br\/>                }<br\/>            ]<br\/>        }<br\/>    ] <br\/>}<\/code><\/pre> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Nobs - Social Share Buttons .webmanifest file<\/span> <\/div> <\/div>\n<p>As you can see on the highlighted lines of code in this file extracted from the mentioned web site, it is an array in JSON format allowing you to list the shortcuts you want to declare. You will find there, for <a href=\"https:\/\/www.w3.org\/TR\/appmanifest\/#shortcutitem-and-its-members\">each item<\/a>:<\/p>\n<ul>\n<li><code>name<\/code>: the text label appearing on the shortcut itself must be short and use an action verb if it allows you to create something or perform an action in the application.<\/li>\n<li><code>shortname<\/code>: this is optional, but the <code>shortname<\/code> can be a shorter name of your action <code>name<\/code>, used if there is not enough space to display the first one.<\/li>\n<li><code>description<\/code>: a text that can be used as additional information by some customers. (not yet found, probably a tooltip later on desktop)<\/li>\n<li><code>url<\/code>: the basis of the web, but also the basis of your action on the application. You can propose a URL with parameters here. Any valid URL structure is accepted to my knowledge.<\/li>\n<li><code>icons<\/code>: a table of icons used to represent the action to be produced. Each icon proposes a set of properties to be declared as well:\n<ul>\n<li><code>src<\/code>: the path to your icon,<\/li>\n<li><code>type<\/code>: the MIME-type of your image (<code>image\/png<\/code>, <code>image\/jpeg<\/code>, <code>image\/svg+xml<\/code>, etc.)<\/li>\n<li><code>purpose<\/code>: how the browser should handle the icon. There are 3 values, the default being <code>any<\/code>, there is also <code>maskable<\/code> and <code>monochrome<\/code>. (<a href=\"https:\/\/www.w3.org\/TR\/appmanifest\/#purpose-member\">W3C Documentation<\/a>)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>PWA Shortcut: design of the icons<\/h3>\n<p>Shortcut icons can be very simple: exactly the same one as your application. However, I advise you to create a different icon for each action, while taking into account the following aspects:<\/p>\n<ul>\n<li><strong>clarity<\/strong>: the icon must be sufficiently understandable, even if the shortcut is associated with a text, try to have an explicit icon next to it.<\/li>\n<li><strong><span lang=\"en\">dark mode<\/span><\/strong>\u00a0: don&#8217;t forget that the icon is inserted in the user interface (the frame that supports shortcuts), this frame can be customized in color (android, windows), often either light (white) or dark (black or very dark gray) depending on the light or dark mode user preferences. The best is to insert your icon in a colored container based on a color of your choice.<\/li>\n<li><strong>monochrome<\/strong>: even though Safari does not yet support these shortcuts, it uses monochrome\u00a0 to create &#8220;pinned elements&#8221; on native apps. So think about making a version with 1 single color of your icon.<\/li>\n<\/ul>\n<figure id=\"attachment_7584\" aria-labelledby=\"figcaption_attachment_7584\" class=\"wp-caption aligncenter\" style=\"width: 344px\"><img decoding=\"async\" class=\"size-full wp-image-7584\" src=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-shortcut-darkmode-lightmode.png\" alt=\"\" width=\"334\" height=\"328\" srcset=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-shortcut-darkmode-lightmode.png 669w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-shortcut-darkmode-lightmode-300x294.png 300w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-shortcut-darkmode-lightmode-600x588.png 600w\" sizes=\"(max-width: 334px) 100vw, 334px\" \/><figcaption id=\"figcaption_attachment_7584\" class=\"wp-caption-text\">Light &amp; Dark mode<\/figcaption><\/figure>\n<p>I personally chose a round shape for these icons, while adopting exactly the same colors as the application&#8217;s icon.<\/p>\n<p>Les raccourcis viennent avec quelques contraintes, pas uniquement technique, qu&#8217;il vaut mieux garder en t\u00eate pour \u00e9viter d&#8217;en abuser.<\/p>\n<h2>Technical and conceptual limitations of PWA Shortcuts<\/h2>\n<h3>Keep the <code>scope<\/code> in mind<\/h3>\n<p>For security reasons (I suppose), all actions and shortcuts must be done within the <a href=\"https:\/\/www.w3.org\/TR\/appmanifest\/#dfn-within-scope-0\">scope of the application<\/a>. For example, I had tried to make a direct access to <a href=\"https:\/\/twitter.com\/wpsharebuttons\">my Twitter account<\/a> for this specific plugin.<\/p>\n<div class=\"code-embed-wrapper\"> <pre class=\"language-php code-embed-pre line-numbers\"  data-line=\"4\" data-start=\"1\" data-line-offset=\"0\"><code class=\"language-php code-embed-code\">{<br\/>    &quot;name&quot;: &quot;Nobs on Twitter&quot;, <br\/>    &quot;description&quot;: &quot;Our Twitter account.&quot;,<br\/>    &quot;url&quot;: &quot;https:\/\/twitter.com\/wpsharebuttons&quot;,<br\/>    &quot;icons&quot;: [<br\/>        {<br\/>            &quot;src&quot;: &quot;\/assets\/img\/picto-twitter.png&quot;,<br\/>            &quot;type&quot;: &quot;image\/png&quot;,<br\/>            &quot;purpose&quot;: &quot;any&quot;<br\/>        }<br\/>    ]<br\/>}<\/code><\/pre> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">Attempt to put a link to Twitter<\/span> <\/div> <\/div>\n<p>Of course, it didn&#8217;t work \ud83d\ude1c<\/p>\n<h3>Avoid putting PWA Shortcuts everywhere<\/h3>\n<p>From a design point of view, don&#8217;t think about putting shortcuts just because it&#8217;s technically possible. First, start by asking yourself if you really need these.<\/p>\n<p>I don&#8217;t have a ready-made answer for you, you will have to conduct your own investigation, especially with the help of a UX Designer or Product Designer. But first of all, if you already have visit statistics on your tool, take the time to analyze:<\/p>\n<ul>\n<li>the most visited pages during a first opening on site\/app (landing pages)<\/li>\n<li>check the most frequent creation actions (opening a blank action)<\/li>\n<li>limit yourself to a maximum of 3 items, beyond that, decision making for users will be more difficult and the clarity of the proposed actions will take a hit.<\/li>\n<\/ul>\n<p>This should give you some food for thought for these first shortcuts.<\/p>\n<p>In my case, I don&#8217;t have any actions to do on my little website. The pages proposed as shortcuts are simply the most visited. I limited myself to 2 to give me the place of an additional action in the long run.<\/p>\n<h3>Browser Compatibility for PWA Shortcuts<\/h3>\n<p>The adoption by browsers is progressive. I was able to test it on Windows 10 with Edge and Chrome in addition to the latest version of Chrome Android. (at the time of writing these lines)<\/p>\n<p class=\"center\"><img decoding=\"async\" class=\"wp-image-7586 alignnone\" src=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-shortcuts-windows-start-menu@2x-1.jpg\" alt=\"\" width=\"547\" height=\"337\" srcset=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-shortcuts-windows-start-menu@2x-1.jpg 993w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-shortcuts-windows-start-menu@2x-1-300x185.jpg 300w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-shortcuts-windows-start-menu@2x-1-600x370.jpg 600w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/pwa-shortcuts-windows-start-menu@2x-1-768x474.jpg 768w\" sizes=\"(max-width: 547px) 100vw, 547px\" \/> <img decoding=\"async\" class=\"wp-image-7588 alignnone\" src=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/shortcut-pwa-chrome-windows@2x-1.jpg\" alt=\"\" width=\"346\" height=\"323\" srcset=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/shortcut-pwa-chrome-windows@2x-1.jpg 452w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/shortcut-pwa-chrome-windows@2x-1-300x280.jpg 300w\" sizes=\"(max-width: 346px) 100vw, 346px\" \/> <img decoding=\"async\" class=\"wp-image-7590 alignnone\" src=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/shortcut-pwa-edge-windows@2x-1.jpg\" alt=\"\" width=\"346\" height=\"323\" srcset=\"https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/shortcut-pwa-edge-windows@2x-1.jpg 452w, https:\/\/www.creativejuiz.fr\/blog\/wp-content\/uploads\/2020\/10\/shortcut-pwa-edge-windows@2x-1-300x280.jpg 300w\" sizes=\"(max-width: 346px) 100vw, 346px\" \/><\/p>\n<p>As you can see, the icons are not present in this mode, the shortcuts take the icon of the browser with which you installed and launched the PWA.<\/p>\n<p>A thought on the subject, a sharing of experience? Come see me on <a href=\"https:\/\/twitter.com\/geoffreycrofte\">Twitter<\/a> or feel free to post a comment!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You have probably already used these shortcuts available at &#8220;force touch&#8221; or &#8220;long touch&#8221; on your mobile application icons? It&#8217;s a way to access shortcuts inside your application to quickly access a section, or directly start a more precise action. It is now possible to do this for your Progressive Web App (PWA).<\/p>\n","protected":false},"author":4,"featured_media":7594,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_bluesky_dont_syndicate":"","_bluesky_syndication_accounts":"","_bluesky_syndication_text":"","footnotes":""},"categories":[650,647],"tags":[778,893],"coauthors":[597],"class_list":["post-7595","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development","category-tutorials","tag-pwa-en","tag-webmanifest-en"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.creativejuiz.fr\/blog\/en\/wp-json\/wp\/v2\/posts\/7595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.creativejuiz.fr\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.creativejuiz.fr\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.creativejuiz.fr\/blog\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.creativejuiz.fr\/blog\/en\/wp-json\/wp\/v2\/comments?post=7595"}],"version-history":[{"count":3,"href":"https:\/\/www.creativejuiz.fr\/blog\/en\/wp-json\/wp\/v2\/posts\/7595\/revisions"}],"predecessor-version":[{"id":7598,"href":"https:\/\/www.creativejuiz.fr\/blog\/en\/wp-json\/wp\/v2\/posts\/7595\/revisions\/7598"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.creativejuiz.fr\/blog\/en\/wp-json\/wp\/v2\/media\/7594"}],"wp:attachment":[{"href":"https:\/\/www.creativejuiz.fr\/blog\/en\/wp-json\/wp\/v2\/media?parent=7595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.creativejuiz.fr\/blog\/en\/wp-json\/wp\/v2\/categories?post=7595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.creativejuiz.fr\/blog\/en\/wp-json\/wp\/v2\/tags?post=7595"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.creativejuiz.fr\/blog\/en\/wp-json\/wp\/v2\/coauthors?post=7595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}