Post

Replies

Boosts

Views

Activity

Request array with AppIntents
Hi, I’m trying to get an array of strings from the user using AppIntents, but I’m encountering an issue. The shortcut ends without prompting the user for input or saving the value, though it doesn’t crash. I need to get the user to input multiple tasks in an array, but the current approach isn’t working as expected. Here’s the current method I’m using: // Short code snippet showing the current method private func collectTasks() async throws -> [String] { var collectedTasks: [String] = tasks ?? [] while true { if !collectedTasks.isEmpty { let addMore = try await $input.requestConfirmation("Would you like to add another task?") if !addMore { break } } let newTask = try await $input.requestValue("Please enter a task:") collectedTasks.append(newTask) } return collectedTasks } The Call func perform() async throws -> some IntentResult { let finalTasks = try await collectTasks() // Some more Code } Any advice or suggestions would be appreciated. Thanks in advance!
0
0
174
2w
Request Array with AppIntent
Hi everyone, i'm trying to request in a AppIntent an array of strings. But I want to give the user the chance to add more than one String. Yet, I do it so: import AppIntent struct AddHomework: AppIntent { // some Parameters @Parameter(title: "Tasks") var tasks: [String]? @Parameter(title: "New Task") //Only for the special request var input: String? private func collectTasks() async throws -> [String] { var collectedTasks: [String] = tasks ?? [] while true { if !collectedTasks.isEmpty { let addMore = try await $input.requestConfirmation(for: "Möchtest du noch eine Aufgabe hinzufügen?") if !addMore { break } } let newTask = try await $input.requestValue("Please enter your task:") collectedTasks.append(newTask) } return collectedTasks } @MainActor func perform() async throws -> some IntentResult { let finalTasks = try await collectTasks() // some more code return .result() } } But this is not working. The Shortcut is ending without requesting anything. But it is not crashing. I would thankfully for some help.
0
0
175
2w