Stuck on attempt to send voice message with SiriKit.
Calling Siri command Send audio message with AppName, it's recording the message and then call func handle(intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void)
But attached Data has length 0 and when I try to get file by direct URL I've got message file:///var/tmp/SiriMessages/E262A828-A24E-452E-BF70-867F5653BEFE.caf: Unable to open «E262A828-A24E-452E-BF70-867F5653BEFE.caf», you have no permissions.
I didn't found any permissions settings so asking for help.
func handle(intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void) {
let userActivity = NSUserActivity(activityType: NSStringFromClass(INSendMessageIntent.self))
let MIMEType = "audio/x-caf"
var resultCode: INSendMessageIntentResponseCode = .failure
var response = INSendMessageIntentResponse(code: resultCode, userActivity: userActivity)
if let audio = intent.attachments!.first?.audioMessageFile {
let networkService = NetworkService() // Test service for uploading files
let audioData = audio.data
let filePath = audio.fileURL!
Task {
var resultCode: INSendMessageIntentResponseCode = .success
var response = INSendMessageIntentResponse(code: resultCode, userActivity: userActivity)
await networkService.uploadAudioMessage(filePath: filePath, withMIMEType: MIMEType) // Here I've got permission error
print("Size of file: \(audioData.count)") // Will output Size of file: 0
print("Result success")
completion(response)
return
}
} else {
print("no voice message attached")
completion(response)
return
}
}