## Summary - Add Siri and Shortcuts actions for music playback, queue management, playlists, favorites, and transport controls. - Bridge native App Intents to the mobile app’s playback and library data. ## Testing - Not run Reviewed-on: #40
43 lines
1.3 KiB
Swift
43 lines
1.3 KiB
Swift
import Foundation
|
|
import AppIntents
|
|
internal import ExpoAppIntents
|
|
internal import ExpoModulesCore
|
|
|
|
/// Registers the app-owned intent types and their system integrations.
|
|
enum MusicAppIntents {
|
|
static func register() {
|
|
Task {
|
|
await AppIntentDispatcher.shared.setShortcutsRefreshHandler {
|
|
AppShortcuts.updateAppShortcutParameters()
|
|
}
|
|
AppShortcuts.updateAppShortcutParameters()
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Registered Expo inline module that wires app-target App Intents code to expo-app-intents.
|
|
/// Do not change the name of this class.
|
|
final class AppIntentsSetup: Module {
|
|
public func definition() -> ExpoModulesCore.ModuleDefinition {
|
|
Name("AppIntentsSetup")
|
|
|
|
AsyncFunction("replaceCatalog") { (kind: String, json: String) in
|
|
try await MusicCatalogStorage.shared.replace(kind: kind, json: json)
|
|
}
|
|
|
|
AsyncFunction("catalogJSON") { (kind: String) in
|
|
let records = try await MusicCatalogStorage.shared.records(kind: kind)
|
|
return String(decoding: try JSONEncoder().encode(records), as: UTF8.self)
|
|
}
|
|
|
|
AsyncFunction("completeInvocation") { (token: String, error: String?) in
|
|
await MusicIntentExecution.shared.complete(token: token, error: error)
|
|
}
|
|
|
|
OnCreate {
|
|
MusicAppIntents.register()
|
|
MusicEntityRegistration.register()
|
|
}
|
|
}
|
|
}
|