Popular Design News of the Week: July 23, 2018 – July 29, 2018

Original Source: https://www.webdesignerdepot.com/2018/07/popular-design-news-of-the-week-july-23-2018-july-29-2018/

Every week users submit a lot of interesting stuff on our sister site Webdesigner News, highlighting great content from around the web that can be of interest to web designers. 

The best way to keep track of all the great stories and news being posted is simply to check out the Webdesigner News site, however, in case you missed some here’s a quick and useful compilation of the most popular designer news that we curated from the past week.

Note that this is only a very small selection of the links that were posted, so don’t miss out and subscribe to our newsletter and follow the site daily for all the news.

The Future of Mobile Web? It’s all About Progressive Web Apps

 

Finally… Capture your Screen Without all that Mess on your Desktop ✨

 

Google Video Shows All-white Redesigns for Gmail, Google Photos, and More

 

Forget About your Logo. Nobody Cares.

 

Fresh Fonts Freshen up your Font News

 

Your Coworker with the Annoying Sit-stand Desk May Be Onto Something

 

20 White Texture Background Graphics

 

What if People were Paid for their Data?

 

We’re Underestimating the Mind-warping Potential of Fake Video

 

5 Ways to Take Better Control of your WordPress Website

 

Keyframes: A Community for Animators

 

Designers Talk: What We Didn’t Expect

 

Hacking User Perception to Make your Websites and Apps Feel Faster

 

Site Design: Emergence

 

Queer UX Experience

 

How to Give Project Estimates—and When not to Estimate at all

 

Timeqube – Beautiful Timer that Helps Waste Less Time in Meetings

 

8 Logo Design Cliches You Should Avoid

 

One Year After Massive Takedowns, Dark Web Marketplaces are Thriving

 

User Research: Is More the Merrier?

 

Netflix is Launching a New TV Interface Starting Today

 

How We Improved Our Landing Page Conversion Rate by 500%

 

Why Logo Placement is Essential to your Company Website

 

7 Design Lessons from Silicon Valley’s Most Important Failure

 

Adobe Shares Pantone’s Summer Trending Colours

 

Want more? No problem! Keep track of top design news from around the web with Webdesigner News.

Add Realistic Chalk and Sketch Lettering Effects with Sketch’it – only $5!

Source

p img {display:inline-block; margin-right:10px;}
.alignleft {float:left;}
p.showcase {clear:both;}
body#browserfriendly p, body#podcast p, div#emailbody p{margin:0;}

Logging Activity With The Web Beacon API

Original Source: https://www.smashingmagazine.com/2018/07/logging-activity-web-beacon-api/

Logging Activity With The Web Beacon API

Logging Activity With The Web Beacon API

Drew McLellan

2018-07-27T13:40:14+02:00
2018-07-27T14:14:35+00:00

The Beacon API is a JavaScript-based Web API for sending small amounts of data from the browser to the web server without waiting for a response. In this article, we’ll look at what that can be useful for, what makes it different from familiar techniques like XMLHTTPRequest (‘Ajax’), and how you can get started using it.

If you know why you want to use Beacon already, feel free to jump directly to the Getting Started section.

What Is The Beacon API For?

The Beacon API is used for sending small amounts of data to a server without waiting for a response. That last part is critical and is the key to why Beacon is so useful — our code never even gets to see a response, even if the server sends one. Beacons are specifically for sending data and then forgetting about it. We don’t expect a response and we don’t get a response.

Think of it like a postcard sent home when on vacation. You put a small amount of data on it (a bit of “Wish you were here” and “The weather’s been lovely”), put it in the mailbox, and you don’t expect a response. No one sends a return postcard saying “Yes, I do wish I was there actually, thank you very much!”

For modern websites and applications, there’s a number of use cases that fall very neatly into this pattern of send-and-forget.

Getting the process just right ain’t an easy task. That’s why we’ve set up ‘this-is-how-I-work’-sessions — with smart cookies sharing what works really well for them. A part of the Smashing Membership, of course.

Explore features →

Smashing TV, with live sessions for professional designers and developers.

Tracking Stats And Analytics Data

The first use case that comes to mind for most people is analytics. Big solutions like Google Analytics might give a good overview of things like page visits, but what if we wanted something more customized? We could write some JavaScript to track what’s happening in a page (maybe how a user interacts with a component, how far they’ve scrolled to, or which articles have been displayed before they follow a CTA) but we then need to send that data to the server when the user leaves the page. Beacon is perfect for this, as we’re just logging the data and don’t need a response.

There’s no reason we couldn’t also cover the sort of mundane tasks often handled by Google Analytics, reporting on the user themselves and the capability of their device and browser. If the user has a logged in session, you could even tie those stats back to a known individual. Whatever data you gather, you can send it back to the server with Beacon.

Debugging And Logging

Another useful application for this behavior is logging information from your JavaScript code. Imagine you have a complex interactive component on your page that works perfectly for all your tests, but occasionally fails in production. You know it’s failing, but you can’t see the error in order to begin debugging it. If you can detect a failure in the code itself, you could then gather up diagnostics and use Beacon to send it all back for logging.

In fact, any logging task can usefully be performed using Beacon, be that creating save-points in a game, collecting information on feature use, or recording results from a multivariate test. If it’s something that happens in the browser that you want the server to know about, then Beacon is likely a contender.

Can’t We Already Do This?

I know what you’re thinking. None of this is new, is it? We’ve been able to communicate from the browser to the server using XMLHTTPRequest for more than a decade. More recently we also have the Fetch API which does much the same thing with a more modern promise-based interface. Given that, why do we need the Beacon API at all?

The key here is that because we don’t get a response, the browser can queue up the request and send it without blocking execution of any other code. As far as the browser is concerned, it doesn’t matter if our code is still running or not, or where the script execution has got to, as there’s nothing to return it can just background the sending of the HTTP request until it’s convenient to send it.

That might mean waiting until CPU load is lower, or until the network is free, or even just sending it right away if it can. The important thing is that the browser queues the beacon and returns control immediately. It does not hold things up while the beacon sends.

To understand why this is a big deal, we need to look at how and when these sorts of requests are issued from our code. Take our example of an analytics logging script. Our code may be timing how long the users spend on a page, so it becomes critical that the data is sent back to the server at the last possible moment. When the user goes to leave a page, we want to stop timing and send the data back home.

Typically, you’d use either the unload or beforeunload event to execute the logging. These are fired when the user does something like following a link on the page to navigate away. The trouble here is that code running on one of the unload events can block execution and delay the unloading of the page. If unloading of the page is delayed, then the loading next page is also delayed, and so the experience feels really sluggish.

Keep in mind how slow HTTP requests can be. If you’re thinking about performance, typically one of the main factors you try to cut down on is extra HTTP requests because going out to the network and getting a response can be super slow. The very last thing you want to do is put that slowness between the activation of a link and the start of the request for the next page.

Beacon gets around this by queuing the request without blocking, returning control immediately back to your script. The browser then takes care of sending that request in the background without blocking. This makes everything much faster, which makes users happier and lets us all keep our jobs.

Getting Started

So we understand what Beacon is, and why we might use it, so let’s get started with some code. The basics couldn’t be simpler:

let result = navigator.sendBeacon(url, data);

The result is boolean, true if the browser accepted and queued the request, and false if there was a problem in doing so.

Using navigator.sendBeacon()

navigator.sendBeacon takes two parameters. The first is the URL to make the request to. The request is performed as an HTTP POST, sending any data provided in the second parameter.

The data parameter can be in one of several formats, all if which are taken directly from the Fetch API. This can be a Blob, a BufferSource, FormData or URLSearchParams — basically any of the body types used when making a request with Fetch.

I like using FormData for basic key-value data as it’s uncomplicated and easy to read back.

// URL to send the data to
let url = ‘/api/my-endpoint’;

// Create a new FormData and add a key/value pair
let data = new FormData();
data.append(‘hello’, ‘world’);

let result = navigator.sendBeacon(url, data);

if (result) {
console.log(‘Successfully queued!’);
} else {
console.log(‘Failure.’);
}

Browser Support

Support in browsers for Beacon is very good, with the only notable exceptions being Internet Explorer (works in Edge) and Opera Mini. For most uses, that should be fine, but it’s worth testing for support before trying to use navigator.sendBeacon.

That’s easy to do:

if (navigator.sendBeacon) {
// Beacon code
} else {
// No Beacon. Maybe fall back to XHR?
}

If Beacon isn’t available and your request is important, you could fall back to a blocking method such as XHR. Depending on your audience and purpose, you might equally choose to not bother.

An Example: Logging Time On A Page

To see this in practice, let’s create a basic system to time how long a user stays on a page. When the page loads we’ll note the time, and when the user leaves the page we’ll send the start time and current time to the server.

As we only care about time spent (not the actual time of day) we can use performance.now() to get a basic timestamp as the page loads:

let startTime = performance.now();

If we wrap up our logging into a function, we can call it when the page unloads.

let logVisit = function() {
// Test that we have support
if (!navigator.sendBeacon) return true;

// URL to send the data to, e.g.
let url = ‘/api/log-visit’;

// Data to send
let data = new FormData();
data.append(‘start’, startTime);
data.append(‘end’, performance.now());
data.append(‘url’, document.URL);

// Let’s go!
navigator.sendBeacon(url, data);
};

Finally, we need to call this function when the user leaves the page. My first instinct was to use the unload event, but Safari on a Mac seems to block the request with a security warning, so beforeunload works just fine for us here.

window.addEventListener(‘beforeunload’, logVisit);

When the page unloads (or, just before it does) our logVisit() function will be called and provided the browser supports the Beacon API our beacon will be sent.

(Note that if there is no Beacon support, we return true and pretend it all worked great. Returning false would cancel the event and stop the page unloading. That would be unfortunate.)

Considerations When Tracking

As so many of the potential uses for Beacon revolve around tracking of activity, I think it would be remiss not to mention the social and legal responsibilities we have as developers when logging and tracking activity that could be tied back to users.

GDPR

We may think of the recent European GDPR laws as they related to email, but of course, the legislation relates to storing any type of personal data. If you know who your users are and can identify their sessions, then you should check what activity you are logging and how it relates to your stated policies.

Often we don’t need to track as much data as our instincts as developers tell us we should. It can be better to deliberately not store information that would identify a user, and then you reduce your likelihood of getting things wrong.

DNT: Do Not Track

In addition to legal requirements, most browsers have a setting to enable the user to express a desire not to be tracked. Do Not Track sends an HTTP header with the request that looks like this:

DNT: 1

If you’re logging data that can track a specific user and the user sends a positive DNT header, then it would be best to follow the user’s wishes and anonymize that data or not track it at all.

In PHP, for example, you can very easily test for this header like so:

if (!empty($_SERVER[‘HTTP_DNT’])) {
// User does not wish to be tracked …
}

In Conclusion

The Beacon API is a really useful way to send data from a page back to the server, particularly in a logging context. Browser support is very broad, and it enables you to seamlessly log data without negatively impacting the user’s browsing experience and the performance of your site. The non-blocking nature of the requests means that the performance is much faster than alternatives such as XHR and Fetch.

If you’d like to read more about the Beacon API, the following sites are worth a look.

“W3C Beacon specification,” W3C Candidate Recommendation
“MDN Beacon documentation,” MDN web docs, Mozilla
“Browser support information,” caniuse.com

Smashing Editorial
(ra, il)

Exclusive Freebie: Communication  Icon Pack

Original Source: https://inspiredm.com/exclusive-freebie-communication-icon-pack/

The power of communication cannot be underestimated, especially not with the Freepik Communication Icon Pack. It has everything that you could think of in relation communication in the modern world. 

From smart slick cameras, tablets, and folders you have everything you can think of. Communication is all around us and is changing as the world evolves and modernizes. This icon pack is a constant reminder of that. There are three versions of each icon available and they are 100 percent editable which means you can customize them to suit your needs.

Each icon is free to download and even better you can find more styles on the Freepik and Flaticon websites. You can use the icons from anything to postcards to stationary. Free for personal and commercial use!

Download this awesome resources from here.

The post Exclusive Freebie: Communication  Icon Pack appeared first on Inspired Magazine.

What it's like to be a Batman artist: Tony S Daniel shares his story

Original Source: http://feedproxy.google.com/~r/CreativeBloq/~3/VJm6L3TFoV0/what-its-like-to-be-a-batman-artist-tony-s-daniel-shares-his-story

Just like the Joker, Tony S Daniel is wrestling with Batman. As we’re interviewing him, issue 45 of the latest series is in its death throes, and it simply won’t die.

Normally, Batman wouldn’t be such a problem for the artist, who’s returning to a character he’s pencilled numerous times during his career. The trouble is that his inker has dropped out mid-issue, so he’s on double duty, drawing and inking his boards on the fly, Fed Ex-ing them off to DC Comics while responding to our questions.

Art techniques: top tutorials for painting and drawing

Long hours aside, Batman is where Tony’s fans want him, and it’s where he wants to be. “It’s like that feeling you get when you go back to your favourite place,” he says. “It’s still what you remember, but you’re older and wiser and maybe you can even appreciate a few details you didn’t first time around. It’s a good feeling.”

Working with writer Tom King, this latest run is kicking off with a new time-travelling storyline featuring Booster Gold, Catwoman and, of course, the Caped Crusader. Tony has always been a fan of a bigger, darker and grittier Batman, a character whose moods are shaped by the murder of his parents in Gotham City. He’s an artist who feels he’s at his most effective when he’s loose and spontaneous.

Aquaman, Wonder Woman, Batman and the Flash striking a heroic pose

This cover variant accompanied the 2017 issue of Justice League that DC published to coincide with the Warner Bros. fi lm based on the series

There’s a sense that Tony wants to get back on track with Batman. His last significant encounter with the character was during the New 52 reboot DC carried out in 2011. Tony relaunched Detective Comics at that time, which features Batman as its lead. The run ended prematurely with Tony feeling a little burned out.

“I was overworked at that time, writing Hawkman, and writing and drawing Detective Comics. It caught up with me real fast and the quality wasn’t what I demanded of myself,” he says.

I’ve learned you have to say ‘no’ to things sometimes. It could be in your own best interest

Tony S Daniel

He continues: “I could’ve stayed on for a couple more years, but I knew it would best to take a break and regroup. I’ve learned you have to say ‘no’ to things sometimes. It could be in your own best interest.”

Batman at his best

For Tony, the best Batman he’s ever drawn was during the R.I.P. story arc with writer Grant Morrison. The partnership between Tony on pencils and Grant weaving a mad storyline began on Batman issue 670, in 2007, with The Resurrection of Ra’s al Ghul. 

That first cover remains one of Tony’s favourites, and fans remember this period as one of the greatest in the character’s history. With the spontaneity of Grant’s plotting matched in Tony’s pencils, many put the artist up there right alongside the likes of Frank Miller and Neal Adams in the Batman pantheon.

Batman looking down on the Joker surrounded by doll heads

Tony’s unsettling cover for Detective Comics, volume 1 – part of DC’s ambitious New 52 relaunch of its titles back in 2011

“That was a magical time for me. I was so into it,” says Tony. “I couldn’t wait to read each script from Grant, because like every other fan, I wanted to know what the hell was going on! It really was a classic story and I’m so proud to have been a part of it.” 

If it was this version of Batman that brought Tony into the mainstream, it was an earlier book called The Tenth that put him on the map within the comics world. First published in 1997 by Image Comics, Tony owned the IP and The Tenth was a platform for him to both write and draw at the same time.

Dynamic and different, it featured young people with supernatural powers, up against Rhazes Darkk and his evil supermonsters. Originally, the plan was for Tony to block out the story and for Beau Smith to write and letter it.

Catwoman feasts on pop corn as she watches Batman fight the Joker

A new era of Batman begins with the current series issue 45, as Tony returns on pencils.

“After the first arc, I realised that I was doing more and more of the writing and dialogue, and thought I’d give it a try. It felt very natural for me,” he says.

“I love being the writer and artist. I do have a greater sense of being the storyteller, as opposed to being the artist only. I will get back to creator-owned at some point. Maybe next year, I hope. Though there’s risks with going down the creator-owned route, I’ve never shied away from risks.”

Writing on the side

After writing and drawing other comics at Image and Dark Horse, Tony was so inspired by the writing side that he took time out of comics to become a screenwriter.

Back in the world of comics, although he’s written and drawn hits like the Batman story Battle for the Cowl, and relaunched Deathstroke as artist-writer, today he prefers to draw alongside a good writer, and keep his screenwriting going on the side. He’s finishing a script with James Bonny, so watch this space.

Deathstroke and Harley Quinn amongst the ruins of Gotham

The cover to Tony’s fourth issue of Deathstroke, featuring Harley Quinn helping to bring Gotham to its knees

At the moment, Tony has his hands full with his current comics. On top of Batman, he’s drawing Damage. Although DC already had a character called Damage, to all intents and purposes the current series is a new launch. It’s got that tell-tale strength and directness you expect from a Tony S Daniel comic, with a fresh feel and – literally – a smashing main character.

“My style has constantly mutated over the years,” says Tony. “I don’t think I’ve ever forced a style change – it’s always happened slowly, organically. I think I have a mix of realism and cartoonishness that I try to balance. I find that if I go too realistic, the work ends up looking flat.”

This article originally appeared in ImagineFX issue 160; subscribe here. 

Related articles:

How to create a comic page5 ways to improve your digital art skillsHow to colour comics

Collective #438

Original Source: http://feedproxy.google.com/~r/tympanus/~3/zfuMSJF18o8/

C438_WOTW

Inspirational Website of the Week: Volt By Drive

A great game-like design with some nice animations. Our pick this week.

Get inspired

C438_NW

Our Sponsor
Earn your master’s in Information Design and Strategy

Learn to blend digital skills like information architecture & experience design in Northwestern’s online master’s program for designers.

Apply now

C438_city

Little Big City

A fantastic project by Yi Shen: generating a real city on a little planet with the help of ClayGL.

Check it out

C438_game

Pyxel

Pyxel is a retro game development environment in Python.

Check it out

C438_fusionjs

Introducing Fusion.js: A Plugin-based Universal Web Framework

Leo Horie from Uber Engineering introduces Fusion.js, an open source web framework for building lightweight, high-performing apps.

Read it

C438_costjs

The Cost Of JavaScript In 2018

Addy Osmani covers some strategies you can use to deliver JavaScript efficiently while still giving users a valuable experience.

Read it

C438_doodles

theDoodleLibrary

A fantastic collection of free, reusable drawings and doodles in a vector (SVG) format.

Check it out

C438_css

CSS exclusions with Queen Bey

Chen Hui Jing writes about CSS Exclusions and new CSS features in general,? and why we should keep them out regardless of current browsers’ support.

Read it

C438_task

Taskbook

Taskbook enables you to effectively manage your tasks and notes across multiple boards from within your terminal.

Check it out

C438_clipboard

The Clipboard API Crashcourse

A practical guide to the Clipboard API by David East.

Check it out

C438_bullshitweb

The Bullshit Web

A very interesting article by Nick Heer on the course the web took concerning unnecessary page load for questionable purposes.

Read it

C438_network

Dynamic resources using the Network Information API and service workers

Learn about the new Network Information API that allows developers to determine the connection types and the underlying connection technology that the user agent is using. By Dean Hume.

Read it

C438_zen

CodeZen

With this tool you can generate shareable and elegant images from your source code.

Check it out

C438_betweenjs

Between.js

A lightweight JavaScript (ES6) tweening library by Alexander Buzin.

Check it out

C438_apps

UI Sources

Get real product insights from the best designed and top grossing apps on the App Store with this email newsletter.

Check it out

C438_native

Performance Techniques in 2017

A slide deck with lots of info on getting native performance with new Web APIs.

Check it out

C438_vunits

The trick to viewport units on mobile

Louis Hoebregts shows an interesting trick to get viewport units behave on mobile.

Read it

C438_reportingobs

ReportingObserver: know your code health

Eric Bidelman writes about the ReportingObserver, a new API that lets you know when your site uses a deprecated API or runs into a browser intervention.

Read it

C438_motion

Improve your motion

An article by Erick Leopoldo with practical tips on how to make animations better.

Read it

C438_font

Free Font: Bivona

A playful, energetic font by Dathan Boardman from Rocket Type.

Get it

C438_loader

Space Loader

A great space themed loader by Chris Gannon.

Check it out

Collective #438 was written by Pedro Botelho and published on Codrops.

Be Legendary. Nike Branding Concept for Tokyo 2020

Original Source: http://feedproxy.google.com/~r/abduzeedo/~3/4wQsSWfJdIg/be-legendary-nike-branding-concept-tokyo-2020

Be Legendary. Nike Branding Concept for Tokyo 2020

Be Legendary. Nike Branding Concept for Tokyo 2020

AoiroStudio
Aug 02, 2018

Daniele Caruso is a freelance illustrator based in Swindon, United Kingdom. He is working mainly in illustration, graphic design and branding. We are taking a look at his branding concept for Nike: Be Legendary, for the upcoming and anticipated Tokyo 2020. With the tagline “legendary”, Daniele included mythological creatures to create an artistic atmosphere alongside with the colour palette that totally reminds me of Dotonbori (the bright heart) from Osaka, Japan. What do you think? Would you like this kind of visual approach if it was from Nike.

More Links
danielecaruso.com
Behance
Be Legendary. Nike Branding Concept for Tokyo 2020Be Legendary. Nike Branding Concept for Tokyo 2020Be Legendary. Nike Branding Concept for Tokyo 2020Be Legendary. Nike Branding Concept for Tokyo 2020

nike
branding
concept
illustration
tokyo


The best colour tools for web designers

Original Source: http://feedproxy.google.com/~r/CreativeBloq/~3/XoqHAngN_VI/the-best-colour-tools-for-web-designers

As web designers, one of the most important choices we make has to do with our colour selections. Choose the wrong ones, and you might just lose out on an opportunity. It's true – the colours we choose can have a psychological impact on those who view them.

For example, red is generally viewed as a high-energy colour, while blue implies calmness and peace. To illustrate this point, consider the colours you might use on a website selling children's toys versus a site for a law firm. Chances are, you'll go with bright, vibrant colours for the former, and muted tones of blue and grey for the latter.

But how do you know which colours work well together? Luckily, you don't have to be a master at colour theory to put together a workable colour palette. To help you with the important task of colour selection, here are some of the best free colour web design tools (plus one special bonus at the end for Mac users).

01. HueSnap

hue snap colour tool

Snap inspiration on the go and turn it into colour palettes

Inspiration can strike at any time. It might be the decor of a hotel room or the light in the park one evening that sparks the inspiration for your next website colour scheme. For when that happens, HueSnap is here to help. You can snap a photo and use HueSnap to extract the colours from the image and make them into a palette. 

The app is tailored for mobile use, and you can save and share your palettes with others. There are plenty of features to help you modify a palette, such as options to choose complementary and compound colours, and your palettes can have up to six colours each.

02. Khroma

khroma colour tools

Khroma uses AI to suggest colours you’ll like

Khroma is an AI colour tool that aims to help you easily browse and compare original colour combinations. With it, users train an AI algorithm to act like an extension of their brain. Users start by picking 50 colours they like, and these colours are used to train a neural network that can recognise hundreds of thousands of other similar colours. Find out more about Khroma and how to use it here.

03. Coolors.co

Laptop, desktop and mobile screens displaying colour palettes

The Explore section includes hundreds – if not thousands – of palette options

Coolors offers a wide variety of tools for adjusting the palette just the way you want it. In addition, you can export your final creation in many different formats so you can use it virtually wherever you want. 

Coolors isn’t just a tool to create a colour palette, it also allows you to view other completed creations from other users so that you can draw inspiration. The Explore section has hundreds (if not thousands) of palettes you can view, save, and edit yourself. Even better, Coolors is available on desktop computers, and as an iOS application, an Adobe Photoshop and Illustrator add-on – and even a Google Chrome Extension for easy access.

04. Adobe Color CC

Colour wheel selection screen with adjustment tools

This has been around a while, but is still incredibly useful

Free tool Adobe Color CC has been around for a while, and it's one of the best colour tools out there for picking a colour palette. Not only can you create your own colour schemes, but you can also explore what others have created. 

Select a colour from the wheel or from an image and apply colour rules such as only using complementary colours, monochromatic colours or shades of the colour you select, to generate a colour palette. Or, click on each colour and explore the colour wheel to customise the selection. As an added bonus, you can save the themes you create to your Adobe library.

05. Colordot

Bars of colours with reference numbers

Use simple mouse gestures to build up your colour palette

Colordot by Hailpixel is an excellent free online tool for creating a colour palette. Using simple mouse gestures, you can select and save colours. Move your mouse back and forth for hue; up and down for lightness; scroll for saturation and click to save a colour to your palette. Click the tog icon to see each colours RGB and HSL values. It also has a $0.99/£0.99 iOS app that allows you to capture colours with your camera.

06. Eggradients

eggradients screen shot

Gradient inspiration and thought-provoking names

Eggradients offers ideas for beautiful gradients to use within your design work, put together by someone with both a great eye for colour and an interesting sense of humour. Each gradient, displayed in an egg shape, comes with its own thought-provoking name. Examples include 'Wozniak’s Broken Heart' for a pale blue and 'Merciful Enemy' for a yellow to green transition. 

07. 147 Colors

Grid of multicoloured swatches

This free tool includes the standard CSS colours

When you're responsible for generating easy-to-read CSS, sometimes using standard colours and colour names is the way to go. Thanks to 147 Colors by Brian Maier Jr, you can get a glimpse of all of them, and pick the ones that work for you. 

It contains the 17 standard colours, plus 130 other CSS colour names. Filter the results by shades of blue, green and so on, or choose from the full rainbow of 147 colours.

08. Canva Color Palette Generator

Canvas tool colour selection screen

Create a colour palette based on an image

The Color Palette Generator by Canva is perfect if you're looking to create a colour palette based around a particular image.  Although other tools offer similar options, Canva’s is super-simple to use: you upload an image and the generator will return a palette of the five main colours contained in it. You can click on the colours you like and copy the HEX value to your clipboard.

Unfortunately, this is where the usefulness of Canva’s offering ends, as this is all you can do with its palette generator – you cannot adjust the colours of the palette. The only other options you have are to copy the hex values provided or upload another photo.

09. Material Design Palette

Material Design Palette selection screen

Create a palette based on Google’s Material Design principles

With Material Design Palette you can select two colours, which are then converted into a full colour palette for you to download, complete with a preview. 

The company also offers Material Design Colors, which enables designers to see the different shades of a colour, along with their corresponding HEX values.

10. ColourCode

Bars of colours with HEX values

Save and export colour palettes as SCSS, LESS or PNG files

ColourCode by Tamino Martinius and Andreas Storm is similar to Colordot, but it offers a bit more guidance. This free tool hits you right in the face, showcasing a background that changes colours with your cursor movement. Besides that, this tool offers different categories for the palette (analogue, triad, quad, monochrome, monochrome light etc). 

With ColourCode, you can set different options along the colour wheel to create an original combination. You can also save your palette or export it as a SCSS or LESS file. You can even export to PNG, if you'd like.

11. Color Calculator

Colour Calculator instruction screen

Select a colour and a colour harmony, and this tool will generate a colour palette

The Color Calculator is straightforward: you select a colour and a colour harmony option. In return, you get back the results of your recommended colour scheme. 

What's nice about this site, however, is that it also goes into a little bit of detail about colour theory and how it relates to your colour choices.

12. HTML Color Code

HTML Color Code download screen

This suite of tools includes a list of standard colour names

This bulging free suite of tools by Dixon & Moe includes an in-depth colour picker with plenty of explanations of colour rules; a series of colour charts featuring flat design colours, Google's Material design scheme and the classic web safe colour palette; and a list of standard HTML colour names and codes. 

This site also offers tutorials and other resources for web designers, and options to export results from its tools as HEX codes, HTML, CSS and SCSS styles.

13. W3Schools: Colors Tutorial

Colors Tutorial naming examples screen

This free tutorial includes links to a number of handy colour tools

If you're looking for an all-in-one solution that includes a guide to colours, as well as a number of different tools, then the Colors Tutorial at W3Schools is the perfect choice.

Not only can you learn about colour theory, colour wheels, and colour hues, but you'll also be able to use the other tools it has, such as the Color Converter. With this tool, you're able to convert any colour to-and-from names, HEX codes, RGB, HSL, HWB and CMYK values.

14. Digital Color Meter (Mac)

Example of Digital Color Meter in action

Mac’s built-in tool lets you grab colours from your screen

OK, Mac users… this one's for you. With your machine's built-in Digital Color Meter tool, you can 'grab' a colour from anywhere on your screen, then get the values for that colour as a decimal, hexadecimal, or percentage. Plus, you can even 'copy' the selected colour as a text or image.

Read more:

If celebrities were Pantone colours3 huge colour trends for 2018How to pick the perfect colour palette every time

How to use Media Queries in JavaScript with matchMedia

Original Source: https://www.sitepoint.com/javascript-media-queries/

When it was first introduced, responsive design was one of the most exciting web layout concepts since CSS replaced tables. The underlying technology uses media queries to determine the viewing device type, width, height, orientation, resolution, aspect ratio, and color depth to serve different stylesheets.

If you thought responsive design was reserved for CSS layouts only, you’ll be pleased to hear media queries can also be used in JavaScript, as this article will explain.

Media Queries in CSS

In the following example, cssbasic.css is served to all devices. But, if it’s a screen with a horizontal width of 500 pixels or greater, csswide.css is also sent:

[code language=”html”]
<link rel="stylesheet" media="all" href="cssbasic.css" />
<link rel="stylesheet" media="(min-width: 500px)" href="csswide.css" />
[/code]

The possibilities are endless and the technique has long been exploited by most websites out there on the Internet. Resizing the width of your browser triggers changes in the layout of the webpage.

With media queries nowadays it’s easy to adapt the design or resize elements in CSS. But what if you need to change the content or functionality? For example, on smaller screens you might want to use a shorter headline, fewer JavaScript libraries, or modify the actions of a widget.

It’s possible to analyze the viewport size in JavaScript but it’s a little messy:

Most browsers support window.innerWidth and window.innerHeight. (IE before version 10 in quirks mode required document.body.clientWidth and document.body.clientHeight.)
window.onresize
All the main browsers support document.documentElement.clientWidth and document.documentElement.clientHeight but it’s inconsistent. Either the window or document dimensions will be returned depending on the browser and mode.

Even if you successfully detect viewport dimension changes, you must calculate factors such as orientation and aspect ratios yourself. There’s no guarantee it’ll match your browser’s assumptions when it applies media query rules in CSS.

The post How to use Media Queries in JavaScript with matchMedia appeared first on SitePoint.

User Experience Psychology And Performance: SmashingConf Videos

Original Source: https://www.smashingmagazine.com/2018/08/smashingconf-ux-videos/

User Experience Psychology And Performance: SmashingConf Videos

User Experience Psychology And Performance: SmashingConf Videos

The Smashing Editorial

2018-08-01T13:30:35+02:00
2018-08-01T15:01:09+00:00

Today, we’d like to shine a light on two videos from our archives as we explore two very different approaches to User Experience (UX). The first explores how we relate our websites to the needs and situations of our visitors, trying to meet them where they are emotionally. The second is a detailed technical exploration into how we measure and track the data around performance as it relates to user experience.

The second video may seem unrelated to the first video; however, while the collecting and analyzing of data might seem very impersonal, the improvements we can make based on the information makes a real difference to the experience of the people we build our sites to serve.

Designing Powerful User Experiences With Psychology

Recorded at the SmashingConf in San Francisco earlier this year, Joe Leech explains how psychology impacts user experience. Joe explains the frustrations people using our products face, and the things happening in their everyday lives and environment that can make interacting with our websites and applications difficult. He goes on to help us understand how we can design in a way to help these visitors rather than frustrate them.

How’s The UX On The Web, Really?

Once you have created a great user experience, how do you know that it is really working well? Especially in terms of site performance, we can track how people are using our sites and examine that data to see what is really happening.

At the SmashingConf in London, Ilya Grigorik was the Mystery Speaker and spoke about the ways to assess performance in real terms, and benchmark your application against other destinations on the web.

Enjoyed listening to these talks? There are many more SmashingConf videos on Vimeo. We’re also getting ready for the upcoming SmashingConf in New York — see you there? 😉

With so much happening on the web, what should we really pay attention to? At SmashingConf New York 2018 ?? we’ll explore everything from PWAs, font loading best practices, web performance and eCommerce UX optimization, to refactoring CSS, design workflows and convincing your clients. With Sarah Drasner, Dan Mall, Sara Soueidan, Jason Grigsby, and many other speakers. Oct 23–24.

Check the speakers →

SmashingConf New York 2018, with Dan Mall, Sara Soueidan, Sarah Drasner and many others.

Smashing Editorial
(ra, il)

Will SiriKit’s Intents Fit Your App? If So, Here’s How To Use Them

Original Source: https://www.smashingmagazine.com/2018/04/sirikit-intents-app-guide/

Will SiriKit’s Intents Fit Your App? If So, Here’s How To Use Them

Will SiriKit’s Intents Fit Your App? If So, Here’s How To Use Them

Lou Franco

2018-04-11T17:00:44+02:00
2018-04-11T15:22:34+00:00

Since iOS 5, Siri has helped iPhone users send messages, set reminders and look up restaurants with Apple’s apps. Starting in iOS 10, we have been able to use Siri in some of our own apps as well.

In order to use this functionality, your app must fit within Apple’s predefined Siri “domains and intents.” In this article, we’ll learn about what those are and see whether our apps can use them. We’ll take a simple app that is a to-do list manager and learn how to add Siri support. We’ll also go through the Apple developer website’s guidelines on configuration and Swift code for a new type of extension that was introduced with SiriKit: the Intents extension.

When you get to the coding part of this article, you will need Xcode (at least version 9.x), and it would be good if you are familiar with iOS development in Swift because we’re going to add Siri to a small working app. We’ll go through the steps of setting up a extension on Apple’s developer website and of adding the Siri extension code to the app.

“Hey Siri, Why Do I Need You?”

Sometimes I use my phone while on my couch, with both hands free, and I can give the screen my full attention. Maybe I’ll text my sister to plan our mom’s birthday or reply to a question in Trello. I can see the app. I can tap the screen. I can type.

But I might be walking around my town, listening to a podcast, when a text comes in on my watch. My phone is in my pocket, and I can’t easily answer while walking.

Getting the process just right ain’t an easy task. That’s why we’ve set up ‘this-is-how-I-work’-sessions — with smart cookies sharing what works really well for them. A part of the Smashing Membership, of course.

Explore features →

Smashing TV, with live sessions for professional designers and developers.

With Siri, I can hold down my headphone’s control button and say, “Text my sister that I’ll be there by two o’clock.” Siri is great when you are on the go and can’t give full attention to your phone or when the interaction is minor, but it requires several taps and a bunch of typing.

This is fine if I want to use Apple apps for these interactions. But some categories of apps, like messaging, have very popular alternatives. Other activities, such as booking a ride or reserving a table in a restaurant, are not even possible with Apple’s built-in apps but are perfect for Siri.

Apple’s Approach To Voice Assistants

To enable Siri in third-party apps, Apple had to decide on a mechanism to take the sound from the user’s voice and somehow get it to the app in a way that it could fulfill the request. To make this possible, Apple requires the user to mention the app’s name in the request, but they had several options of what to do with the rest of the request.

It could have sent a sound file to the app.
The benefit of this approach is that the app could try to handle literally any request the user might have for it. Amazon or Google might have liked this approach because they already have sophisticated voice-recognition services. But most apps would not be able to handle this very easily.
It could have turned the speech into text and sent that.
Because many apps don’t have sophisticated natural-language implementations, the user would usually have to stick to very particular phrases, and non-English support would be up to the app developer to implement.
It could have asked you to provide a list of phrases that you understand.
This mechanism is closer to what Amazon does with Alexa (in its “skills” framework), and it enables far more uses of Alexa than SiriKit can currently handle. In an Alexa skill, you provide phrases with placeholder variables that Alexa will fill in for you. For example, “Alexa, remind me at $TIME$ to $REMINDER$” — Alexa will run this phrase against what the user has said and tell you the values for TIME and REMINDER. As with the previous mechanism, the developer needs to do all of the translation, and there isn’t a lot of flexibility if the user says something slightly different.
It could define a list of requests with parameters and send the app a structured request.
This is actually what Apple does, and the benefit is that it can support a variety of languages, and it does all of the work to try to understand all of the ways a user might phrase a request. The big downside is that you can only implement handlers for requests that Apple defines. This is great if you have, for example, a messaging app, but if you have a music-streaming service or a podcast player, you have no way to use SiriKit right now.

Similarly, there are three ways for apps to talk back to the user: with sound, with text that gets converted, or by expressing the kind of thing you want to say and letting the system figure out the exact way to express it. The last solution (which is what Apple does) puts the burden of translation on Apple, but it gives you limited ways to use your own words to describe things.

The kinds of requests you can handle are defined in SiriKit’s domains and intents. An intent is a type of request that a user might make, like texting a contact or finding a photo. Each intent has a list of parameters — for example, texting requires a contact and a message.

A domain is just a group of related intents. Reading a text and sending a text are both in the messaging domain. Booking a ride and getting a location are in the ride-booking domain. There are domains for making VoIP calls, starting workouts, searching for photos and a few more things. SiriKit’s documentation contains a full list of domains and their intents.

A common criticism of Siri is that it seems unable to handle requests as well as Google and Alexa, and that the third-party voice ecosystem enabled by Apple’s competitors is richer.

I agree with those criticisms. If your app doesn’t fit within the current intents, then you can’t use SiriKit, and there’s nothing you can do. Even if your app does fit, you can’t control all of the words Siri says or understands; so, if you have a particular way of talking about things in your app, you can’t always teach that to Siri.

The hope of iOS developers is both that Apple will greatly expand its list of intents and that its natural language processing becomes much better. If it does that, then we will have a voice assistant that works without developers having to do translation or understand all of the ways of saying the same thing. And implementing support for structured requests is actually fairly simple to do — a lot easier than building a natural language parser.

Another big benefit of the intents framework is that it is not limited to Siri and voice requests. Even now, the Maps app can generate an intents-based request of your app (for example, a restaurant reservation). It does this programmatically (not from voice or natural language). If Apple allowed apps to discover each other’s exposed intents, we’d have a much better way for apps to work together, (as opposed to x-callback style URLs).

Finally, because an intent is a structured request with parameters, there is a simple way for an app to express that parameters are missing or that it needs help distinguishing between some options. Siri can then ask follow-up questions to resolve the parameters without the app needing to conduct the conversation.

The Ride-Booking Domain

To understand domains and intents, let’s look at the ride-booking domain. This is the domain that you would use to ask Siri to get you a Lyft car.

Apple defines how to ask for a ride and how to get information about it, but there is actually no built-in Apple app that can actually handle this request. This is one of the few domains where a SiriKit-enabled app is required.

You can invoke one of the intents via voice or directly from Maps. Some of the intents for this domain are:

Request a ride
Use this one to book a ride. You’ll need to provide a pick-up and drop-off location, and the app might also need to know your party’s size and what kind of ride you want. A sample phrase might be, “Book me a ride with <appname>.”
Get the ride’s status
Use this intent to find out whether your request was received and to get information about the vehicle and driver, including their location. The Maps app uses this intent to show an updated image of the car as it is approaching you.
Cancel a ride
Use this to cancel a ride that you have booked.

For any of this intents, Siri might need to know more information. As you’ll see when we implement an intent handler, your Intents extension can tell Siri that a required parameter is missing, and Siri will prompt the user for it.

The fact that intents can be invoked programmatically by Maps shows how intents might enable inter-app communication in the future.

Note: You can get a full list of domains and their intents on Apple’s developer website. There is also a sample Apple app with many domains and intents implemented, including ride-booking.

Adding Lists And Notes Domain Support To Your App

OK, now that we understand the basics of SiriKit, let’s look at how you would go about adding support for Siri in an app that involves a lot of configuration and a class for each intent you want to handle.

The rest of this article consists of the detailed steps to add Siri support to an app. There are five high-level things you need to do:

Prepare to add a new extension to the app by creating provisioning profiles with new entitlements for it on Apple’s developer website.
Configure your app (via its plist) to use the entitlements.
Use Xcode’s template to get started with some sample code.
Add the code to support your Siri intent.
Configure Siri’s vocabulary via plists.

Don’t worry: We’ll go through each of these, explaining extensions and entitlements along the way.

To focus on just the Siri parts, I’ve prepared a simple to-do list manager, List-o-Mat.

An animated GIF showing a demo of List-o-MatMaking lists in List-o-Mat (Large preview)

You can find the full source of the sample, List-o-Mat, on GitHub.

To create it, all I did was start with the Xcode Master-Detail app template and make both screens into a UITableView. I added a way to add and delete lists and items, and a way to check off items as done. All of the navigation is generated by the template.

To store the data, I used the Codable protocol, (introduced at WWDC 2017), which turns structs into JSON and saves it in a text file in the documents folder.

I’ve deliberately kept the code very simple. If you have any experience with Swift and making view controllers, then you should have no problem with it.

Now we can go through the steps of adding SiriKit support. The high-level steps would be the same for any app and whichever domain and intents you plan to implement. We’ll mostly be dealing with Apple’s developer website, editing plists and writing a bit of Swift.

For List-o-Mat, we’ll focus on the lists and notes domain, which is broadly applicable to things like note-taking apps and to-do lists.

In the lists and notes domain, we have the following intents that would make sense for our app.

Get a list of tasks.
Add a new task to a list.

Because the interactions with Siri actually happen outside of your app (maybe even when you app is not running), iOS uses an extension to implement this.

The Intents Extension

If you have not worked with extensions, you’ll need to know three main things:

An extension is a separate process. It is delivered inside of your app’s bundle, but it runs completely on its own, with its own sandbox.
Your app and extension can communicate with each other by being in the same app group. The easiest way is via the group’s shared sandbox folders (so, they can read and write to the same files if you put them there).
Extensions require their own app IDs, profiles and entitlements.

To add an extension to your app, start by logging into your developer account and going to the “Certificates, Identifiers, & Profiles” section.

Updating Your Apple Developer App Account Data

In our Apple developer account, the first thing we need to do is create an app group. Go to the “App Groups” section under “Identifiers” and add one.

A screenshot of the Apple developer website dialog for registering an app groupRegistering an app group (Large preview)

It must start with group, followed by your usual reverse domain-based identifier. Because it has a prefix, you can use your app’s identifier for the rest.

Then, we need to update our app’s ID to use this group and to enable Siri:

Go to the “App IDs” section and click on your app’s ID;
Click the “Edit” button;
Enable app groups (if not enabled for another extension).
A screenshot of Apple developer website enabling app groups for an app IDEnable app groups (Large preview)

Then configure the app group by clicking the “Edit” button. Choose the app group from before.
A screenshot of the Apple developer website dialog to set the app group nameSet the name of the app group (Large preview)

Enable SiriKit.
A screenshot of SiriKit being enabledEnable SiriKit (Large preview)

Click “Done” to save it.

Now, we need to create a new app ID for our extension:

In the same “App IDs” section, add a new app ID. This will be your app’s identifier, with a suffix. Do not use just Intents as a suffix because this name will become your module’s name in Swift and would then conflict with the real Intents.
A screenshot of the Apple developer screen to create an app IDCreate an app ID for the Intents extension (Large preview)

Enable this app ID for app groups as well (and set up the group as we did before).

Now, create a development provisioning profile for the Intents extension, and regenerate your app’s provisioning profile. Download and install them as you would normally do.

Now that our profiles are installed, we need to go to Xcode and update the app’s entitlements.

Updating Your App’s Entitlements In Xcode

Back in Xcode, choose your project’s name in the project navigator. Then, choose your app’s main target, and go to the “Capabilities” tab. In there, you will see a switch to turn on Siri support.

A screenshot of Xcode’s entitlements screen showing SiriKit is enabledEnable SiriKit in your app’s entitlements. (Large preview)

Further down the list, you can turn on app groups and configure it.

A screenshot of Xcode's entitlements screen showing the app group is enabled and configuredConfigure the app’s app group (Large preview)

If you have set it up correctly, you’ll see this in your app’s .entitlements file:

A screenshot of the App's plist showing that the entitlements are setThe plist shows the entitlements that you set (Large preview)

Now, we are finally ready to add the Intents extension target to our project.

Adding The Intents Extension

We’re finally ready to add the extension. In Xcode, choose “File” → “New Target.” This sheet will pop up:

A screenshot showing the Intents extension in the New Target dialog in XcodeAdd the Intents extension to your project (Large preview)

Choose “Intents Extension” and click the “Next” button. Fill out the following screen:

A screeenshot from Xcode showing how you configure the Intents extensionConfigure the Intents extension (Large preview)

The product name needs to match whatever you made the suffix in the intents app ID on the Apple developer website.

We are choosing not to add an intents UI extension. This isn’t covered in this article, but you could add it later if you need one. Basically, it’s a way to put your own branding and display style into Siri’s visual results.

When you are done, Xcode will create an intents handler class that we can use as a starting part for our Siri implementation.

The Intents Handler: Resolve, Confirm And Handle

Xcode generated a new target that has a starting point for us.

The first thing you have to do is set up this new target to be in the same app group as the app. As before, go to the “Capabilities” tab of the target, and turn on app groups, and configure it with your group name. Remember, apps in the same group have a sandbox that they can use to share files with each other. We need this in order for Siri requests to get to our app.

List-o-Mat has a function that returns the group document folder. We should use it whenever we want to read or write to a shared file.

func documentsFolder() -> URL? {
return FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: “group.com.app-o-mat.ListOMat”)
}

For example, when we save the lists, we use this:

func save(lists: Lists) {
guard let docsDir = documentsFolder() else {
fatalError(“no docs dir”)
}

let url = docsDir.appendingPathComponent(fileName, isDirectory: false)

// Encode lists as JSON and save to url
}

The Intents extension template created a file named IntentHandler.swift, with a class named IntentHandler. It also configured it to be the intents’ entry point in the extension’s plist.

A screenshot from Xcode showing how the IntentHandler is configured as an entry pointThe intent extension plist configures IntentHandler as the entry point

In this same plist, you will see a section to declare the intents we support. We’re going to start with the one that allows searching for lists, which is named INSearchForNotebookItemsIntent. Add it to the array under IntentsSupported.

A screenshot in Xcode showing that the extension plist should list the intents it handlesAdd the intent’s name to the intents plist (Large preview)

Now, go to IntentHandler.swift and replace its contents with this code:

import Intents

class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any? {
switch intent {
case is INSearchForNotebookItemsIntent:
return SearchItemsIntentHandler()
default:
return nil
}
}
}

The handler function is called to get an object to handle a specific intent. You can just implement all of the protocols in this class and return self, but we’ll put each intent in its own class to keep it better organized.

Because we intend to have a few different classes, let’s give them a common base class for code that we need to share between them:

class ListOMatIntentsHandler: NSObject {
}

The intents framework requires us to inherit from NSObject. We’ll fill in some methods later.

We start our search implementation with this:

class SearchItemsIntentHandler: ListOMatIntentsHandler,
INSearchForNotebookItemsIntentHandling {
}

To set an intent handler, we need to implement three basic steps

Resolve the parameters.
Make sure required parameters are given, and disambiguate any you don’t fully understand.
Confirm that the request is doable.
This is often optional, but even if you know that each parameter is good, you might still need access to an outside resource or have other requirements.
Handle the request.
Do the thing that is being requested.

INSearchForNotebookItemsIntent, the first intent we’ll implement, can be used as a task search. The kinds of requests we can handle with this are, “In List-o-Mat, show the grocery store list” or “In List-o-Mat, show the store list.”

Aside: “List-o-Mat” is actually a bad name for a SiriKit app because Siri has a hard time with hyphens in apps. Luckily, SiriKit allows us to have alternate names and to provide pronunciation. In the app’s Info.plist, add this section:

A screenshot from Xcode showing that the app plist can add alternate app names and pronunciationsAdd alternate app name’s and pronunciation guides to the app plist

This allows the user to say “list oh mat” and for that to be understood as a single word (without hyphens). It doesn’t look ideal on the screen, but without it, Siri sometimes thinks “List” and “Mat” are separate words and gets very confused.

Resolve: Figuring Out The Parameters

For a search for notebook items, there are several parameters:

the item type (a task, a task list, or a note),
the title of the item,
the content of the item,
the completion status (whether the task is marked done or not),
the location it is associated with,
the date it is associated with.

We require only the first two, so we’ll need to write resolve functions for them. INSearchForNotebookItemsIntent has methods for us to implement.

Because we only care about showing task lists, we’ll hardcode that into the resolve for item type. In SearchItemsIntentHandler, add this:

func resolveItemType(for intent: INSearchForNotebookItemsIntent,
with completion: @escaping (INNotebookItemTypeResolutionResult) -> Void) {

completion(.success(with: .taskList))
}

So, no matter what the user says, we’ll be searching for task lists. If we wanted to expand our search support, we’d let Siri try to figure this out from the original phrase and then just use completion(.needsValue()) if the item type was missing. Alternatively, we could try to guess from the title by seeing what matches it. In this case, we would complete with success when Siri knows what it is, and we would use completion(.notRequired()) when we are going to try multiple possibilities.

Title resolution is a little trickier. What we want is for Siri to use a list if it finds one with an exact match for what you said. If it’s unsure or if there is more than one possibility, then we want Siri to ask us for help in figuring it out. To do this, SiriKit provides a set of resolution enums that let us express what we want to happen next.

So, if you say “Grocery Store,” then Siri would have an exact match. But if you say “Store,” then Siri would present a menu of matching lists.

We’ll start with this function to give the basic structure:

func resolveTitle(for intent: INSearchForNotebookItemsIntent, with completion: @escaping (INSpeakableStringResolutionResult) -> Void) {
guard let title = intent.title else {
completion(.needsValue())
return
}

let possibleLists = getPossibleLists(for: title)
completeResolveListName(with: possibleLists, for: title, with: completion)
}

We’ll implement getPossibleLists(for:) and completeResolveListName(with:for:with:) in the ListOMatIntentsHandler base class.

getPossibleLists(for:) needs to try to fuzzy match the title that Siri passes us with the actual list names.

public func getPossibleLists(for listName: INSpeakableString) -> [INSpeakableString] {
var possibleLists = [INSpeakableString]()
for l in loadLists() {
if l.name.lowercased() == listName.spokenPhrase.lowercased() {
return [INSpeakableString(spokenPhrase: l.name)]
}
if l.name.lowercased().contains(listName.spokenPhrase.lowercased()) || listName.spokenPhrase.lowercased() == “all” {
possibleLists.append(INSpeakableString(spokenPhrase: l.name))
}
}
return possibleLists
}

We loop through all of our lists. If we get an exact match, we’ll return it, and if not, we’ll return an array of possibilities. In this function, we’re simply checking to see whether the word the user said is contained in a list name (so, a pretty simple match). This lets “Grocery” match “Grocery Store.” A more advanced algorithm might try to match based on words that sound the same (for example, with the Soundex algorithm),

completeResolveListName(with:for:with:) is responsible for deciding what to do with this list of possibilities.

public func completeResolveListName(with possibleLists: [INSpeakableString], for listName: INSpeakableString, with completion: @escaping (INSpeakableStringResolutionResult) -> Void) {
switch possibleLists.count {
case 0:
completion(.unsupported())
case 1:
if possibleLists[0].spokenPhrase.lowercased() == listName.spokenPhrase.lowercased() {
completion(.success(with: possibleLists[0]))
} else {
completion(.confirmationRequired(with: possibleLists[0]))
}
default:
completion(.disambiguation(with: possibleLists))
}
}

If we got an exact match, we tell Siri that we succeeded. If we got one inexact match, we tell Siri to ask the user if we guessed it right.

If we got multiple matches, then we use completion(.disambiguation(with: possibleLists)) to tell Siri to show a list and let the user pick one.

Now that we know what the request is, we need to look at the whole thing and make sure we can handle it.

Confirm: Check All Of Your Dependencies

In this case, if we have resolved all of the parameters, we can always handle the request. Typical confirm() implementations might check the availability of external services or check authorization levels.

Because confirm() is optional, we could just do nothing, and Siri would assume we could handle any request with resolved parameters. To be explicit, we could use this:

func confirm(intent: INSearchForNotebookItemsIntent, completion: @escaping (INSearchForNotebookItemsIntentResponse) -> Void) {
completion(INSearchForNotebookItemsIntentResponse(code: .success, userActivity: nil))
}

This means we can handle anything.

Handle: Do It

The final step is to handle the request.

func handle(intent: INSearchForNotebookItemsIntent, completion: @escaping (INSearchForNotebookItemsIntentResponse) -> Void) {
guard
let title = intent.title,
let list = loadLists().filter({ $0.name.lowercased() == title.spokenPhrase.lowercased()}).first
else {
completion(INSearchForNotebookItemsIntentResponse(code: .failure, userActivity: nil))
return
}

let response = INSearchForNotebookItemsIntentResponse(code: .success, userActivity: nil)
response.tasks = list.items.map {
return INTask(title: INSpeakableString(spokenPhrase: $0.name),
status: $0.done ? INTaskStatus.completed : INTaskStatus.notCompleted,
taskType: INTaskType.notCompletable,
spatialEventTrigger: nil,
temporalEventTrigger: nil,
createdDateComponents: nil,
modifiedDateComponents: nil,
identifier: “(list.name)t($0.name)”)
}
completion(response)
}

First, we find the list based on the title. At this point, resolveTitle has already made sure that we’ll get an exact match. But if there’s an issue, we can still return a failure.

When we have a failure, we have the option of passing a user activity. If your app uses Handoff and has a way to handle this exact type of request, then Siri might try deferring to your app to try the request there. It will not do this when we are in a voice-only context (for example, you started with “Hey Siri”), and it doesn’t guarantee that it will do it in other cases, so don’t count on it.

This is now ready to test. Choose the intent extension in the target list in Xcode. But before you run it, edit the scheme.

A screenshot from Xcode showing how to edit a schemeEdit the scheme of the the intent to add a sample phrase for debugging.

That brings up a way to provide a query directly:

A screenshot from Xcode showing the edit scheme dialogAdd the sample phrase to the Run section of the scheme. (Large preview)

Notice, I am using “ListOMat” because of the hyphens issue mentioned above. Luckily, it’s pronounced the same as my app’s name, so it should not be much of an issue.

Back in the app, I made a “Grocery Store” list and a “Hardware Store” list. If I ask Siri for the “store” list, it will go through the disambiguation path, which looks like this:

An animated GIF showing Siri handling a request to show the Store listSiri handles the request by asking for clarification. (Large preview)

If you say “Grocery Store,” then you’ll get an exact match, which goes right to the results.

Adding Items Via Siri

Now that we know the basic concepts of resolve, confirm and handle, we can quickly add an intent to add an item to a list.

First, add INAddTasksIntent to the extension’s plist:

A screenshot in XCode showing the new intent being added to the plistAdd the INAddTasksIntent to the extension plist (Large preview)

Then, update our IntentHandler’s handle function.

override func handler(for intent: INIntent) -> Any? {
switch intent {
case is INSearchForNotebookItemsIntent:
return SearchItemsIntentHandler()
case is INAddTasksIntent:
return AddItemsIntentHandler()
default:
return nil
}
}

Add a stub for the new class:

class AddItemsIntentHandler: ListOMatIntentsHandler, INAddTasksIntentHandling {
}

Adding an item needs a similar resolve for searching, except with a target task list instead of a title.

func resolveTargetTaskList(for intent: INAddTasksIntent, with completion: @escaping (INTaskListResolutionResult) -> Void) {

guard let title = intent.targetTaskList?.title else {
completion(.needsValue())
return
}

let possibleLists = getPossibleLists(for: title)
completeResolveTaskList(with: possibleLists, for: title, with: completion)
}

completeResolveTaskList is just like completeResolveListName, but with slightly different types (a task list instead of the title of a task list).

public func completeResolveTaskList(with possibleLists: [INSpeakableString], for listName: INSpeakableString, with completion: @escaping (INTaskListResolutionResult) -> Void) {

let taskLists = possibleLists.map {
return INTaskList(title: $0, tasks: [], groupName: nil, createdDateComponents: nil, modifiedDateComponents: nil, identifier: nil)
}

switch possibleLists.count {
case 0:
completion(.unsupported())
case 1:
if possibleLists[0].spokenPhrase.lowercased() == listName.spokenPhrase.lowercased() {
completion(.success(with: taskLists[0]))
} else {
completion(.confirmationRequired(with: taskLists[0]))
}
default:
completion(.disambiguation(with: taskLists))
}
}

It has the same disambiguation logic and behaves in exactly the same way. Saying “Store” needs to be disambiguated, and saying “Grocery Store” would be an exact match.

We’ll leave confirm unimplemented and accept the default. For handle, we need to add an item to the list and save it.

func handle(intent: INAddTasksIntent, completion: @escaping (INAddTasksIntentResponse) -> Void) {
var lists = loadLists()
guard
let taskList = intent.targetTaskList,
let listIndex = lists.index(where: { $0.name.lowercased() == taskList.title.spokenPhrase.lowercased() }),
let itemNames = intent.taskTitles, itemNames.count > 0
else {
completion(INAddTasksIntentResponse(code: .failure, userActivity: nil))
return
}

// Get the list
var list = lists[listIndex]

// Add the items
var addedTasks = [INTask]()
for item in itemNames {
list.addItem(name: item.spokenPhrase, at: list.items.count)
addedTasks.append(INTask(title: item, status: .notCompleted, taskType: .notCompletable, spatialEventTrigger: nil, temporalEventTrigger: nil, createdDateComponents: nil, modifiedDateComponents: nil, identifier: nil))
}

// Save the new list
lists[listIndex] = list
save(lists: lists)

// Respond with the added items
let response = INAddTasksIntentResponse(code: .success, userActivity: nil)
response.addedTasks = addedTasks
completion(response)
}

We get a list of items and a target list. We look up the list and add the items. We also need to prepare a response for Siri to show with the added items and send it to the completion function.

This function can handle a phrase like, “In ListOMat, add apples to the grocery list.” It can also handle a list of items like, “rice, onions and olives.”

A screenshot of the simulator showing Siri adding items to the grocery store listSiri adds a few items to the grocery store list

Almost Done, Just A Few More Settings

All of this will work in your simulator or local device, but if you want to submit this, you’ll need to add a NSSiriUsageDescription key to your app’s plist, with a string that describes what you are using Siri for. Something like “Your requests about lists will be sent to Siri” is fine.

You should also add a call to:

INPreferences.requestSiriAuthorization { (status) in }

Put this in your main view controller’s viewDidLoad to ask the user for Siri access. This will show the message you configured above and also let the user know that they could be using Siri for this app.

A screenshot of the dialog that a device pops up when you ask for Siri permissionThe device will ask for permission if you try to use Siri in the app.

Finally, you’ll need to tell Siri what to tell the user if the user asks what your app can do, by providing some sample phrases:

Create a plist file in your app (not the extension), named AppIntentVocabulary.plist.
Fill out the intents and phrases that you support.

A screenshot of the AppIntentVocabulary.plist showing sample phrasesAdd an AppIntentVocabulary.plist to list the sample phrases that will invoke the intent you handle. (Large preview)

There is no way to really know all of the phrases that Siri will use for an intent, but Apple does provide a few samples for each intent in its documentation. The sample phrases for task-list searching show us that Siri can understand “Show me all my notes on <appName>,” but I found other phrases by trial and error (for example, Siri understands what “lists” are too, not just notes).

Summary

As you can see, adding Siri support to an app has a lot of steps, with a lot of configuration. But the code needed to handle the requests was fairly simple.

There are a lot of steps, but each one is small, and you might be familiar with a few of them if you have used extensions before.

Here is what you’ll need to prepare for a new extension on Apple’s developer website:

Make an app ID for an Intents extension.
Make an app group if you don’t already have one.
Use the app group in the app ID for the app and extension.
Add Siri support to the app’s ID.
Regenerate the profiles and download them.

And here are the steps in Xcode for creating Siri’s Intents extension:

Add an Intents extension using the Xcode template.
Update the entitlements of the app and extension to match the profiles (groups and Siri support).
Add your intents to the extension’s plist.

And you’ll need to add code to do the following things:

Use the app group sandbox to communicate between the app and extension.
Add classes to support each intent with resolve, confirm and handle functions.
Update the generated IntentHandler to use those classes.
Ask for Siri access somewhere in your app.

Finally, there are some Siri-specific configuration settings:

Add the Siri support security string to your app’s plist.
Add sample phrases to an AppIntentVocabulary.plist file in your app.
Run the intent target to test; edit the scheme to provide the phrase.

OK, that is a lot, but if your app fits one of Siri’s domains, then users will expect that they can interact with it via voice. And because the competition for voice assistants is so good, we can only expect that WWDC 2018 will bring a bunch more domains and, hopefully, much better Siri.

Further Reading

“SiriKit,” Apple
The technical documentation contains the full list of domains and intents.
“Guides and Sample Code,” Apple
Includes code for many domains.
“Introducing SiriKit” (video, Safari only), WWDC 2016 Apple
“What’s New in SiriKit” (video, Safari only), WWDC 2017, Apple
Apple introduces lists and notes
“Lists and Notes,” Apple
The full list of lists and notes intents.

Smashing Editorial
(da, ra, al, il)