sirikit par julien coudsi
TRANSCRIPT
![Page 1: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/1.jpg)
SIRIKIT
COCOAHEADS - MONTPELLIER – 17 NOVEMBRE 2016
![Page 2: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/2.jpg)
AU SOMMAIRE…
• Quoi de neuf ?
• Traiter une demande
• Ajouter du vocabulaire
• Personnaliser l’affichage
• Démo
28.11.16 BACKELITE 2
![Page 3: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/3.jpg)
QUOI DE NEUF ?
![Page 4: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/4.jpg)
QUOI DE NEUF AVEC SIRIKIT ?
28.11.16 BACKELITE 4
• A partir d’iOS 10, Siri s’ouvre aux applications tierces
• Domaines disponibles : Réservation de véhicule
Messages
Photos
Paiements
Communication audio et vidéo
Fitness
Restaurants (avec Plans)
Carplay
![Page 5: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/5.jpg)
TRAITER UNE DEMANDE
![Page 6: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/6.jpg)
PRE-REQUIS
28.11.16 BACKELITE 6
• Une application iOS existante
• Implémenter le code de l’application utilisé par Siri dans un framework
• Utiliser un conteneur partagé pour les ressources communes
• iOS 10 / Xcode 8
![Page 7: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/7.jpg)
COMMENT CA MARCHE ?
28.11.16 BACKELITE 7
• Utilisation d’une Intents Extension
• Un « intent » correspond à une demande de l’utilisateur
INExtension
Intent handler B 1 - Resolve
« Envoi un message »
2 - Confirm
3 - Handle
Action
INIntentResponse
INIntent
Intent handler A
![Page 8: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/8.jpg)
INTENTS ET DOMAINES
A chaque domaine sa liste d’intents :
• Messageso INSendMessageIntent
o INSearchForMessagesIntent
o INSetMessagesAttributes
• Paiementso INSendPaymentIntent
o INRequestPaymentIntent
etc …
![Page 9: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/9.jpg)
CONFIGURATION DU PROJET
28.11.16 BACKELITE 9
• Info.plist de l’extension
• Autoriser l’application à utiliser Siri• Capability Siri activée• App id supportant SiriKit
• Info.plist de l’application
![Page 10: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/10.jpg)
INEXTENSION
28.11.16 BACKELITE 10
• Point d’entrée de l’extension
• Appelle le bon intent handler
class IntentExtension: INExtension {
override func handler(for intent: INIntent) -> Any? {
if intent is INSendMessageIntent {
return MessagesIntentHandler()
} else if intent is INStartAudioCallIntent {
return AudioCallIntentHandler()
} else {
return nil
}
}
}
![Page 11: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/11.jpg)
INTENT HANDLER - RESOLVE
28.11.16 BACKELITE 11
• Vérification des paramètres de l’intent
• Peut solliciter l’utilisateur pour des précisions
func resolveRecipients(forSendMessage intent: INSendMessageIntent, with completion: @escaping ([INPersonResolutionResult]) -> Void)
{
guard let recipients = intent.recipients else {
return
}
if recipients.count == 0 {
completion([INPersonResolutionResult.needsValue()])
} else {
completion([INPersonResolutionResult.success(with: recipients[0])])
}
}
![Page 12: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/12.jpg)
INTENT HANDLER - CONFIRM
28.11.16 BACKELITE 12
• Validation finale de l’intent avant son traitement
• Sollicite l’utilisateur dans certains cas :• Demandes irréversibles
• Transactions financières
func confirm(sendMessage intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void) {
completion(INSendMessageIntentResponse(code: .ready, userActivity: nil))
}
![Page 13: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/13.jpg)
INTENT HANDLER - HANDLE
28.11.16 BACKELITE 13
• Réalise la tâche associée à l’intent
• Renvoie une réponse
func handle(sendMessage intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void) {
var success = false
if let recipients = intent.recipients {
success = ContactsManager.sharedManager.sendMessage(to: recipients)
}
completion(INSendMessageIntentResponse(code: success ? .success : .failure, userActivity: nil))
}
![Page 14: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/14.jpg)
AJOUTER DU VOCABULAIRE
![Page 15: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/15.jpg)
VOCABULAIRE SPECIFIQUE A UN UTILISATEUR
28.11.16 BACKELITE 15
• Restreint aux catégories suivantes : Noms de contacts
Groupes de contact
Tags de photo
Noms d’albums photos
Noms d’exercices (fitness)
Profils de voiture (CarPlay)
DispatchQueue(label: "SiriVocabulary").async {
let contactNicknames:NSOrderedSet = ["JeanMi", "Zozor", "Blop", "Toto"]
INVocabulary.shared().setVocabularyStrings(contactNicknames, of: .contactName)
}
• Utilise l’API INVocabulary depuis l’application
![Page 16: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/16.jpg)
VOCABULAIRE COMMUN A TOUS LES UTILISATEURS
28.11.16 BACKELITE 16
• Utilise le fichier AppIntentVocabulary.plist
• Restreint aux catégories suivantes : Options de réservation d’un véhicule
Noms d’exercices (fitness)
![Page 17: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/17.jpg)
APPINTENTVOCABULARY.PLIST
28.11.16 BACKELITE 17
![Page 18: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/18.jpg)
PERSONNALISER L’AFFICHAGE
![Page 19: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/19.jpg)
PRINCIPE
28.11.16 BACKELITE 19
• Enrichir l’interface lors des échanges avec l’utilisateur
• Utilisation d’une Intents UI Extension
• Restreint aux domaines suivants Messages
Paiements
Réservation de véhicule
Fitness
![Page 20: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/20.jpg)
CONFIGURATION DU PROJET
28.11.16 BACKELITE 20
• Info.plist de l’extension
• Ajout du storyboard et d’un unique ViewController associé
![Page 21: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/21.jpg)
CONFIGURATION DU VIEW CONTROLLER
28.11.16 BACKELITE 21
• Implémentation du protocole INUIHostedViewControlling
func configure(with interaction: INInteraction!, context: INUIHostedViewContext, completion: ((CGSize) -> Void)!) {
...
if let completion = completion {
completion(self.extensionContext!.hostedViewMaximumAllowedSize)
}
}
• Implémentation du protocole INUIHostedViewSiriProviding pour masquer la vue par défaut dans Siri
var displaysMessage: Bool {
return true
}
![Page 22: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/22.jpg)
DEMO
![Page 23: Sirikit par Julien Coudsi](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58789d1e1a28ab42588b4c3b/html5/thumbnails/23.jpg)
www.backelite.com
CONTACTEZ-NOUSCOUDSI Julien
Développeur iOS
28.11.16 BACKELITE 23