Contents

updateAudioAffinity

An intent schema that sets the like state of an audio item to liked, unliked, or unset.

Declaration

var updateAudioAffinity: some AppSchemaIntent { get }

Discussion

To make your app’s actions available to Apple Intelligence, conform your AppIntent to a schema that describes your action to the system. If your app’s functionality aligns with the audio domain and one of your app’s actions matches the updateAudioAffinity schema, you can generate the properties and protocol conformance the schema requires for your intent implementation with the @AppIntent( .audio.updateAudioAffinity) Swift macro. To make your app work with Siri, see Apple Intelligence and Siri AI.

The following example shows an intent that conforms to the updateAudioAffinity schema:

@AppIntent(schema: .audio.updateAudioAffinity)
struct UpdateAudioAffinityIntent {
    var affinityState: <#AffinityState#>
    var target: <#AudioItem#>

    func perform() async throws -> some IntentResult {
        <#code#>
    }
}

Define a @UnionValue enumeration for the target parameter, as in the following example, by typing the first few characters of audio_audioItem in Xcode and selecting it from the code-completion suggestions.

@UnionValue
enum AudioItem {
    case song(<#SongEntity#>)
    case album(<#AlbumEntity#>)
    case artist(<#ArtistEntity#>)
    case playlist(<#PlaylistEntity#>)
    case songCollection(<#SongCollectionEntity#>)
    case classicalMusicRecording(<#ClassicalMusicRecordingEntity#>)
    case liveRadioStation(<#LiveRadioStationEntity#>)
    case algorithmicRadioStation(<#AlgorithmicRadioStationEntity#>)
    case radioShowEpisode(<#RadioShowEpisodeEntity#>)
    case radioShow(<#RadioShowEntity#>)
    case podcastShow(<#PodcastShowEntity#>)
    case podcastEpisode(<#PodcastEpisodeEntity#>)
    case podcastCollection(<#PodcastCollectionEntity#>)
    case audiobook(<#MediaBookEntity#>)
    case ambientSound(<#AmbientSoundEntity#>)
    case newsBrief(<#NewsBriefEntity#>)
    case newsProvider(<#NewsProviderEntity#>)
}

The schema supports the following system experiences:

  • Siri

  • Shortcuts

For more information about the App Intents framework and the experiences it supports, see Getting started with the App Intents framework.

See Also

Actions