Hello,
I have an AppIntent
that uses the AudioPlaybackIntent
to trigger my app to open and initiate an AVPlayer
that plays back a media stream I control. When the phone is unlocked, everything works as I expect. The app opens and plays the audio.
However, when the phone is locked, any attempt to invoke the intent causes a "Request Code" dialog to be displayed. This seems counter to what I would expect with the AudioPlaybackIntent
usage. Am I able to accomplish what I'm after here with AppIntents
? Does the fact that I'm using openAppWhenRun
require me to have the phone unlocked somehow?
import AppIntents
import Foundation
struct PlayStationAppIntent: AudioPlaybackIntent {
static var title: LocalizedStringResource = "Play radio station"
static var description: IntentDescription = .init("Play radio station")
static var notification: Notification.Name = .init("playStation")
static var openAppWhenRun: Bool = true
init() {}
func perform() async throws -> some IntentResult {
AudioPlayerService.shared.play()
return .result()
}
}