contributors |
---|
zntfdr |
- These are the most popular Siri interactions with voice (covering 90% of all utterances):
- The better your Siri support is, the more likely it is that people will make more complicated Siri requests.
- help Siri understand the user intent
- User vocabulary:
- user/personalized items
- shared with Siri via
INVocabulary
API - the items order is by priority (put more important items first)
let vocabulary = INVocabulary.shared()
let playlistNames = NSOrderedSet(objects: "70s punk classics")
vocabulary.setVocabularyStrings(playlistNames, of: .mediaPlaylistTitle)
-
- Here's how to set it:
// Set our playlist title in user vocabulary so we get the proper Siri intent
let vocabulary = INVocabulary.shared()
let playlistNames = NSOrderedSet(objects: "70s punk classics")
vocabulary.setVocabularyStrings(playlistNames, of: .mediaPlaylistTitle)
- Global vocabulary:
- general static vocabulary
- defined in
appIntentVocabulary.plist
- only include things that are particular to your app, don't include popular music or podcast entities, as those are generally already recognized by Siri as part of its NL model
- example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ParameterVocabularies</key>
<array>
<dict>
<key>ParameterNames</key>
<array>
<string>INPlayMediaIntent.playlistTitle</string>
</array>
<key>ParameterVocabulary</key>
<array>
<dict>
<key>VocabularyItemSynonyms</key>
<array>
<dict>
<key>VocabularyItemPhrase</key>
<string>70s punk anthems</string>
</dict>
</array>
<key>VocabularyItemIdentifier</key>
<string>70s punk anthems</string>
</dict>
</array>
</dict>
</array>
</dict>
</plist>
- Use
MPRemoteCommandCenter
to handle playback intents like "next track" and more (this is the same center used to respond playback actions in the lock screen) - Siri reads the center's
nowPlayingInfo
to answer questions reguarding the current playing song (set properties such asMPMediaItemPropertyTitle
,MPMediaItemPropertyArtist
,MPMediaItemPropertyAlbumTitle
)