Get started with Wind Down Shortcuts
March 22, 2021
Wind Down can help people get ready for sleep by offering easy access to calming sounds, soothing audio stories, or a meditation session — and even prepare them for the day ahead. You can enable Wind Down Shortcuts for your app to provide quick access to these kinds of features, making sure people have easy access to everything that can help them with their evening routine.
Meet Wind Down Shortcuts
As part of iOS 14’s Sleep experience, people can create Wind Down shortcuts in the Health app’s Sleep setup flow, adding specific shortcuts they’d like to see on their Lock screen while Wind Down is active. People can also configure these shortcuts from the Shortcuts app’s Sleep mode collection, which appears once someone adds their first Wind Down shortcut. People can add existing or new shortcuts to their Sleep mode collection by flipping on the “Show in Sleep Mode” switch in any shortcut's detail view within the app.
And to make it even easier for people to discover relevant shortcut actions for Sleep mode, you can use the Wind Down API to showcase intents from your app in the Wind Down setup flow.
Explore Wind Down Shortcuts with a sample project
If you’d like to learn more about how you can surface app intents as Wind Down Shortcuts, the WWDC20 video “Integrate your app with Wind Down” offers an overview of this feature and includes a sample code project to help you get started. Sample code projects allow you to explore implementations and understand how new features integrate into an existing project.
Note: In addition to Xcode and the sample code project, you’ll need an iPhone or iPod touch to explore and test out the full Sleep experience. For more setup instructions see the README in the sample project. After building and running the sample project for the first time on your test device, your sample shortcuts will appear in the Health app during Sleep setup.
Within the project, check out the function updateBedtimeShortcutSuggestions
in the file named SoundLibraryDataManager+Intents.swift. This function defines shortcuts for featured soundscapes the user may want to play and adds them to INVoiceShortcutCenter
so the system can offer these shortcuts in the Health app and at other appropriate times.
You can add availability information to an intent like so:
playMediaIntent.shortcutAvailability = .sleepMusic
This signals the category for the shortcut within the Wind Down Shortcuts selection.
The sleepMusic
value is appropriate for an app that offers audio like sleep soundscapes, bedtime music, or tinnitus relief. When the value is present, this intent will show up in the Music area of Wind Down during the Sleep experience setup.
You can learn more about this specific value or discover some of the other available Wind Down values within Xcode’s inline documentation:
- Select
.sleepMusic
within the sample code. - Control-click or right click and choose Show Quick Help from the context menu to learn more about the value.
- Choose the
INShortcutAvailabilityOptions
documentation page — available in both Swift and Objective-C — to preview availability options.
Other values for intents include:
sleepMindfulness
sleepJournaling
sleepPodcasts
sleepReading
sleepWrapUpYourDay
sleepYogaAndStretching
To see how an intent shows up inside a different category, you can replace .sleepMusic
with one of these other values and run your app again. When you build and run your sample app, it will donate these updated intents to the system using this line of code:
INVoiceShortcutCenter.shared.setShortcutSuggestions(newMediaIntents)
Now, when you relaunch the Health app and the Sleep settings screen, the intent will be listed under the new category you chose. Remember: When offering Wind Down shortcut options for your own app, choose the value that’s best for your donated intent or intents. (And if you’re building something designed to be experienced earlier in the day — say, an adrenaline-pumping video game — you may not want to donate intents for the Sleep experience at all.)
Explore intent donations
Within the sample project, you can also learn more about how apps can donate intents. Explore the play(tracks:)
function in TrackTableViewController.swift. The sample app will call this function every time media is played directly in the app.
The PlayRequest
initializer creates an intent with the .sleepMedia
availability option. Then donatePlayRequestToSystem()
donates an INInteraction
to the system with that intent.
private func play(tracks: [Track]?) {
let request = PlayRequest(container: libraryContainer, tracks: tracks)
SoundLibraryDataManager.shared.donatePlayRequestToSystem(request)
if let itemsToPlay = AudioPlaybackManager.shared.resolveItems(for: request) {
AudioPlaybackManager.shared.play(itemsToPlay)
}
}
Note: Visit the BedtimeIntents
target inside the sample project, and you’ll notice that INPlayMediaIntent
is also defined in the Supported Intents section.
Make the code your own Now that you understand how the sample app provides intents for Wind Down and the Sleep experience, you can continue to modify it and experiment. For example, you could use the Media Player framework to play anything in a person’s library instead of the audio file included with the sample project; you can also add intents for other Wind Down activities like a checklist for taking medicine and brushing teeth. Don’t forget to list any new intent types to your project’s Supported Intents section.
Creating an Intents App Extension
Dig into design
When creating intents for Wind Down Shortcuts, consider how someone’s device will display these items. Most people will be viewing your shortcut on their Lock screen as part of several other shortcuts. As such, be both concise and descriptive in naming the subtitles for your intents. Think of them as a brief instruction: What is happening when you run this shortcut? Why might someone want to include it in their bedtime routine?
Human Interface Guidelines: App Shortcuts
... And to all a good night
When you offer quality intents for Wind Down Shortcuts, it can inspire people to adopt your app as part of their sleep routine. Once implemented, these intents can also work with other learning technologies such as Widgets, Smart Stacks, and the Shortcuts app to surface more accurately, promote better usage of your app, and improve the quality of people’s daily — and nightly — lives.
Resources
Learn more about integrating your app with Wind Down
Adding Shortcuts for Wind Down
Creating an Intents App Extension
Adding User Interactivity with Siri Shortcuts and the Shortcuts App