Extending Your Apps with SiriKit

Similar documents
Introduction to Siri Shortcuts

What s New in SiriKit

Building for Voice with Siri Shortcuts

Introducing SiriKit. Hey Siri, say hello to apps #WWDC16. App Frameworks. Session 217

Using and Extending the Xcode Source Editor

What s New in tvos #WWDC16. App Frameworks. Session 206. Hans Kim tvos Engineer

Implementing UI Designs in Interface Builder

What s New in tvos 12

Introducing Password AutoFill for Apps

Enhancing your apps for the next dimension of touch

What s New in Xcode App Signing

Mastering UIKit on tvos

Monetize and Promote Your App with iad

Enabling Your App for CarPlay

Managing Documents In Your ios Apps

Modern User Interaction on ios

Seamless Linking to Your App

Advanced Notifications

Introducing On Demand Resources

What s New in imessage Apps

Leveraging Touch Input on ios

What s New in Testing

Media and Gaming Accessibility

What s New in watchos

Touch Bar Fundamentals

Quick Interaction Techniques for watchos

Data Delivery with Drag and Drop

Building Watch Apps #WWDC15. Featured. Session 108. Neil Desai watchos Engineer

Building Apps with Dynamic Type

Creating Complications with ClockKit Session 209

Introducing the Modern WebKit API

New UIKit Support for International User Interfaces

ios Accessibility Developing for everyone Session 201 Ian Fisch ios Accessibility

Getting the Most Out of HealthKit

Getting the Most out of Playgrounds in Xcode

Introducing the Photos Frameworks

imessage Apps and Stickers, Part 2

New Ways to Work with Workouts

Introducing Swift Playgrounds

What's New in Core Spotlight

Accessibility on OS X

WatchKit In-Depth, Part 2

What s New in Core Data?

Building Faster in Xcode

Creating Audio Apps for watchos

Accessibility on ios. Developing for everyone. Frameworks #WWDC14. Session 210 Clare Kasemset ios Accessibility

What s New in MapKit. App Frameworks #WWDC17. Fredrik Olsson

Using Grouped Notifications

Core ML in Depth. System Frameworks #WWDC17. Krishna Sridhar, Core ML Zach Nation, Core ML

Creating Extensions for ios and OS X, Part Two

Mastering Drag and Drop

View Controller Advancements for ios8

Your Apps and the Future of macos Security

Advanced Scrollviews and Touch Handling Techniques

Designing for Apple Watch

What s New in CloudKit

What's New in UIKit Dynamics and Visual Effects Session 229

Optimizing Swift Performance Session 409

Localizing with Xcode 9

What s New in Swift Playgrounds

What s New in SpriteKit

Designing Great Apple Watch Experiences

Finding Bugs Using Xcode Runtime Tools

CarPlay Audio and Navigation Apps

Advances in TVMLKit. App Frameworks #WWDC17. Trevor Cortez, Localization Engineer Parry Panesar, tvos Engineer Jeremy Foo, tvos Engineer

What s New in NSCollectionView Session 225

Improving your Existing Apps with Swift

Thread Sanitizer and Static Analysis

Advances in AVFoundation Playback

lecture 10 UI/UX and Programmatic Design cs : spring 2018

Mysteries of Auto Layout, Part 1

INTRODUCTION TO ARCHITECTING YOUR IOS APP

Creating Great App Previews

What s New in Notifications

Automatic Strong Passwords and Security Code AutoFill

Writing Energy Efficient Apps

What s New in Energy Debugging

What s New in ARKit 2

Advanced Debugging and the Address Sanitizer

Cocoa Touch Best Practices

Vision Framework. Building on Core ML. Media #WWDC17. Brett Keating, Apple Manager Frank Doepke, He who wires things together

What s New in Cocoa for macos

App Extension Best Practices

Adopting Advanced Features of the New UI

Storyboards and Controllers on OS X

Creating Extensions for Safari

Getting to Know Swift Package Manager

Cross Platform Nearby Networking

Power, Performance, and Diagnostics

Adapting to the New UI of OS X Yosemite

Integrating Apps and Content with AR Quick Look

Engineering for Testability

Understanding Undefined Behavior

Localization Best Practices on tvos

What s New in TVMLKit

Audio Unit Extensions

Core Data Best Practices

Use the API or contact customer service to provide us with the following: General ios Android App Name (friendly one-word name)

What s New in HomeKit

Introducing MusicKit. Media #WWDC17. Tim Parthemore, MusicKit Services Joel Lopes Da Silva, ios Music

Transcription:

App Frameworks #WWDC16 Extending Your Apps with SiriKit Session 225 Vineet Khosla SiriKit Engineering Diana Huang SiriKit Engineering Scott Andrus SiriKit Engineering 2016 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

Adding SiriKit Intents Extension Intents UI Extension App

Adding SiriKit Intents Extension Intents UI Extension App Resolve Confirm Handle

Agenda Preparing to adopt SiriKit

Agenda Preparing to adopt SiriKit Adding your first Intents extension

Agenda Preparing to adopt SiriKit Adding your first Intents extension Providing a user interface in Siri

UnicornChat

Preparing to Adopt SiriKit

Preparing to Adopt SiriKit

Preparing to Adopt SiriKit Embedded frameworks

Preparing to Adopt SiriKit Embedded frameworks Unit tests

Preparing to Adopt SiriKit Embedded frameworks Unit tests Architecting your extensions

Preparing to Adopt SiriKit Embedded frameworks

Preparing to Adopt SiriKit Embedded frameworks Networking

Preparing to Adopt SiriKit Embedded frameworks Networking Data model

Preparing to Adopt SiriKit Embedded frameworks Networking Data model Decision-making logic

Preparing to Adopt SiriKit Embedded frameworks Networking Data model Decision-making logic User interfaces

Preparing to Adopt SiriKit Embedded frameworks Data Decision-making model logic Networking User interfaces

Preparing to Adopt SiriKit Embedded frameworks Data Decision-making model logic Networking User interfaces App Extension Best Practices WWDC 2015

Preparing to Adopt SiriKit Unit tests

Preparing to Adopt SiriKit Unit tests Mock intents

Preparing to Adopt SiriKit Unit tests Mock intents Make sure your app responds appropriately

Preparing to Adopt SiriKit Architecting your extensions SendMessageIntent StartAudioCallIntent StartVideoCallIntent

Preparing to Adopt SiriKit Architecting your extensions SendMessageIntent StartAudioCallIntent StartVideoCallIntent

Preparing to Adopt SiriKit Architecting your extensions SendMessageIntent StartAudioCallIntent StartVideoCallIntent

Preparing to Adopt SiriKit Architecting your extensions SendMessageIntent StartAudioCallIntent StartVideoCallIntent

Adding Your First Intents Extension Diana Huang SiriKit Engineering

Getting Started

Getting Started Add extension target

Getting Started Add extension target Configure Info.plist

Getting Started Add extension target Configure Info.plist Modify principal class

Intents Extension Adding an extension target

Intents Extension Adding an extension target

Intents Extension Adding an extension target

Intents Extension Info.plist

Intents Extension Info.plist Info.plist NSExtension NSExtensionAttributes IntentsSupported IntentsRestrictedWhileLocked

Intents Extension Info.plist Info.plist NSExtension NSExtensionAttributes IntentsSupported IntentsRestrictedWhileLocked

Intents Extension Info.plist Info.plist NSExtension NSExtensionAttributes IntentsSupported IntentsRestrictedWhileLocked

Intents Extension Principal class

Intents Extension Principal class Subclass of INExtension

Intents Extension Principal class Subclass of INExtension INIntentHandlerProviding

Intents Extension Principal class Subclass of INExtension INIntentHandlerProviding handlerforintent

Intents Extension Principal class Subclass of INExtension INIntentHandlerProviding handlerforintent handler class must conform to specific intent handling protocol

Demo Creating my first Intents extension

Resolve, Confirm, Handle Resolve

Resolve, Confirm, Handle Resolve Validate and clarify parameters

Resolve, Confirm, Handle Resolve Validate and clarify parameters Implement it if you might need Siri to help ask users

Resolve, Confirm, Handle Resolve

Resolve, Confirm, Handle Resolve recipients

Resolve, Confirm, Handle Resolve Contact search recipients

Resolve, Confirm, Handle Resolve Contact search recipients Exactly one match

Resolve, Confirm, Handle Resolve Contact search recipients Exactly one match Two or more matches

Resolve, Confirm, Handle Resolve Contact search recipients Exactly one match Two or more matches No match

Resolve, Confirm, Handle Resolve Contact search Exactly one match Resolve recipients Two or more matches No match

Resolve, Confirm, Handle Resolve Resolve recipients

Resolve, Confirm, Handle Resolve Contact search Resolve recipients

Resolve, Confirm, Handle Resolve Contact search Resolve recipients content

Resolve, Confirm, Handle Resolve Contact search Resolve recipients content Need a value to proceed

Resolve, Confirm, Handle Confirm Resolve recipients content

Resolve, Confirm, Handle Confirm Resolve recipients content Confirm

Resolve, Confirm, Handle Confirm Dry run Resolve recipients content Tell Siri how it went Confirm

Resolve, Confirm, Handle Confirm Dry run Resolve recipients content Tell Siri how it went Confirm authenticated?

Resolve, Confirm, Handle Handle Just handle it! Resolve recipients content Again, tell Siri how it went Confirm authenticated? Handle

Demo Filling in my app logic

NSUserActivity Resume state in your app

NSUserActivity Resume state in your app Siri creates one by default

NSUserActivity Resume state in your app Siri creates one by default ActivityType is intent class name

NSUserActivity Resume state in your app Siri creates one by default ActivityType is intent class name You can provide one to pass custom data

NSUserActivity Resume state in your app Siri creates one by default ActivityType is intent class name You can provide one to pass custom data INInteraction

Demo Providing my own NSUserActivity

User-Specific Vocabulary

User-Specific Vocabulary Phrases unique to your app and user

User-Specific Vocabulary Phrases unique to your app and user e.g. contact names

User-Specific Vocabulary Phrases unique to your app and user e.g. contact names Help Siri understand what users mean

User-Specific Vocabulary Phrases unique to your app and user e.g. contact names Help Siri understand what users mean INVocabulary API call from main app

User-Specific Vocabulary Phrases unique to your app and user e.g. contact names Help Siri understand what users mean INVocabulary API call from main app NOT your extension

// User-Specific Vocabulary - UnicornChat class UCAddressBookManager { // This method is called whenever there is a contact change func updatesiriknowledgeofcontacts() { // provide the updated list of favorites' unicorn names to Siri var unicornnames = OrderedSet(array: self.sortedfavoriteunicornnames) INVocabulary.shared().setVocabularyStrings(unicornNames, of: INVocabularyStringType.contactName) } }

// User-Specific Vocabulary - UnicornChat class UCAddressBookManager { // This method is called whenever there is a contact change func updatesiriknowledgeofcontacts() { // provide the updated list of favorites' unicorn names to Siri var unicornnames = OrderedSet(array: self.sortedfavoriteunicornnames) INVocabulary.shared().setVocabularyStrings(unicornNames, of: INVocabularyStringType.contactName) } }

// User-Specific Vocabulary - UnicornChat class UCAddressBookManager { // This method is called whenever there is a contact change func updatesiriknowledgeofcontacts() { // provide the updated list of favorites' unicorn names to Siri var unicornnames = OrderedSet(array: self.sortedfavoriteunicornnames) INVocabulary.shared().setVocabularyStrings(unicornNames, of: INVocabularyStringType.contactName) } }

// User-Specific Vocabulary - UnicornChat class UCAddressBookManager { // This method is called whenever there is a contact change func updatesiriknowledgeofcontacts() { // provide the updated list of favorites' unicorn names to Siri DispatchQueue(label: "UCSiriVocabulary").asynchronously(execute: { () -> Void in var unicornnames = OrderedSet(array: self.sortedfavoriteunicornnames) INVocabulary.shared().setVocabularyStrings(unicornNames, of: INVocabularyStringType.contactName) }) } }

// User-Specific Vocabulary - UnicornChat class UCAddressBookManager { // This method is called whenever there is a contact change func updatesiriknowledgeofcontacts() { // provide the updated list of favorites' unicorn names to Siri DispatchQueue(label: "UCSiriVocabulary").asynchronously(execute: { () -> Void in var unicornnames = OrderedSet(array: self.sortedfavoriteunicornnames) INVocabulary.shared().setVocabularyStrings(unicornNames, of: INVocabularyStringType.contactName) }) } }

// User-Specific Vocabulary - UnicornChat class UCAddressBookManager { // This method is called whenever there is a contact change func updatesiriknowledgeofcontacts() { // provide the updated list of favorites' unicorn names to Siri DispatchQueue(label: "UCSiriVocabulary").asynchronously(execute: { () -> Void in var unicornnames = OrderedSet(array: self.sortedfavoriteunicornnames) INVocabulary.shared().setVocabularyStrings(unicornNames, of: INVocabularyStringType.contactName) }) } }

Providing a User Interface with SiriKit Scott Andrus SiriKit Engineering

UI Extensions Increase Your App s Impact

UI Extensions Increase Your App s Impact Your view alongside Siri

UI Extensions Increase Your App s Impact Your view alongside Siri Experiences unique to your application

UI Extensions Increase Your App s Impact Your view alongside Siri Experiences unique to your application User-specific customization

UI Extensions Increase Your App s Impact Your view alongside Siri Experiences unique to your application User-specific customization Information Siri might not otherwise show

UI Extensions Increase Your App s Impact Your view alongside Siri Experiences unique to your application User-specific customization Information Siri might not otherwise show

Add UI Extension Target to Xcode How to get started

Add UI Extension Target to Xcode How to get started Add Intents UI Extension target

Add UI Extension Target to Xcode How to get started Add Intents UI Extension target Embed in application

Intents UI Extension Info.plist Info.plist NSExtension NSExtensionAttributes IntentsSupported

Intents UI Extension Info.plist Info.plist NSExtension NSExtensionAttributes IntentsSupported

Siri

Siri configure(with interaction:...)

UI extension Siri configure(with interaction:...)

UI extension Siri UIViewController : INUIHostedViewControlling configure(with interaction:...)

UI extension Siri INInteraction UIViewController : INUIHostedViewControlling configure(with interaction:...)

INInteraction Breaking it down INIntent INIntentResponse INInteraction INIntentHandlingStatus

INInteraction Breaking it down The handled (or to-be-handled) INIntent INIntent INIntentResponse INInteraction INIntentHandlingStatus

INInteraction Breaking it down The handled (or to-be-handled) INIntent INIntent The provided INIntentResponse INInteraction INIntentResponse INIntentHandlingStatus

INInteraction Breaking it down The handled (or to-be-handled) INIntent INIntent The provided INIntentResponse INIntentHandlingStatus INInteraction INIntentResponse INIntentHandlingStatus

Implementing Your View Controller

Implementing Your View Controller Principal class

Implementing Your View Controller Principal class Subclass of UIViewController

Implementing Your View Controller Principal class Subclass of UIViewController Configure with interaction

Implementing Your View Controller Principal class Subclass of UIViewController Configure with interaction Provided view context

Implementing Your View Controller Principal class Subclass of UIViewController Configure with interaction Provided view context

Implementing Your View Controller Principal class Subclass of UIViewController Configure with interaction Provided view context

Implementing Your View Controller Principal class Subclass of UIViewController Configure with interaction Provided view context Desired size in the completion

Demo Building a SiriKit UI extension

Siri Gives You Override Control

Siri Gives You Override Control Implement INUIHostedViewSiriProviding

Siri Gives You Override Control Implement INUIHostedViewSiriProviding Properties for displaying messages and maps

Siri Gives You Override Control Implement INUIHostedViewSiriProviding Properties for displaying messages and maps Opt-in to displaying a particular interface

Siri Gives You Override Control Implement INUIHostedViewSiriProviding Properties for displaying messages and maps Opt-in to displaying a particular interface Siri will accommodate your view s content

class IntentViewController: UIViewController, INUIHostedViewControlling, func configure(with interaction: INInteraction!, context: INUIHostedViewContext, completion: ((CGSize) -> Void)!) { // Configure your view completion(self.extensioncontext!.hostedviewmaximumallowedsize) } }

class IntentViewController: UIViewController, INUIHostedViewControlling, INUIHostedViewSiriProviding { func configure(with interaction: INInteraction!, context: INUIHostedViewContext, completion: ((CGSize) -> Void)!) { // Configure your view completion(self.extensioncontext!.hostedviewmaximumallowedsize) } var displaysmessage: Bool { return true } }

class IntentViewController: UIViewController, INUIHostedViewControlling, INUIHostedViewSiriProviding { func configure(with interaction: INInteraction!, context: INUIHostedViewContext, completion: ((CGSize) -> Void)!) { // Configure your view completion(self.extensioncontext!.hostedviewmaximumallowedsize) } var displaysmessage: Bool { return true } }

class IntentViewController: UIViewController, INUIHostedViewControlling, INUIHostedViewSiriProviding { func configure(with interaction: INInteraction!, context: INUIHostedViewContext, completion: ((CGSize) -> Void)!) { // Configure your view completion(self.extensioncontext!.hostedviewmaximumallowedsize) } var displaysmessage: Bool { return true } }

Demo Telling Siri about our interface

Considerations

Considerations Be memory conscious

Considerations Be memory conscious Minimum and maximum view sizes

Considerations Be memory conscious Minimum and maximum view sizes Flexible and adaptive layout patterns

Summary

Summary Prepare to adopt SiriKit

Summary Prepare to adopt SiriKit Add your first Intents extension

Summary Prepare to adopt SiriKit Add your first Intents extension Provide a user interface in Siri

More Information https://developer.apple.com/wwdc16/225

Related Sessions Introducing SiriKit Presidio Wednesday 5:00PM App Extension Best Practices WWDC 2015

Labs SiriKit Lab Frameworks Lab C Thursday 3:00PM SiriKit Lab Frameworks Lab B Friday 9:00AM