ios – AppIntent with IntentCurrencyAmount parameter make Siri loop on asking parameter


I try to use appIntent with Siri to start a transaction in my SwiftUI iOS app, the transaction is done by my own framework inside the app after extracting the parameter from the AppIntent amount and currency propertie, everything work fine when using shortcut to trigger the intent since the currencyAmount input parameter is asked graphically by shortcut. The problem appear when the appIntent is launch by a SIRI command. Siri is looping on asking the parameter and seams to not understand at all the answer.

shortcut input
shortcut input graphical input request

Here is the code that I use to create my appIntent

import AppIntents


struct OpenTransaction : AppIntent {
  static var title: LocalizedStringResource = "Start a transaction"
  
  static var openAppWhenRun: Bool = true
  
  @Parameter(title: "Montant",
             currencyCodes: ["EUR"],
             inclusiveRange: (lowerBound: 0.01, upperBound: 100000000),
             requestValueDialog: IntentDialog("Une transaction de quel montant ?")
  )
  var amount: IntentCurrencyAmount
  
  @MainActor
  func perform() async throws -> some IntentResult {
    print(amount)
    
    return .result()
  }
  
  static var parameterSummary: some ParameterSummary {
    Summary("Lancer une transaction de \(\.$amount)")
  }
}

struct TapAutoShortcuts : AppShortcutsProvider {
  static var appShortcuts: [AppShortcut] {
    AppShortcut(
      intent: OpenTransaction(), phrases: ["Lancer une transaction avec \(.applicationName)"], shortTitle: "Lancer une transaction", systemImageName: "gear"
    )
  }
}

Intent from shortcut trigger the perform method and intent from Siri diction is not triggering the perform method.

I did try to initialise the parameter with a default value but it is not possible with IntentCurrencyParameter. I tried to force currency to have a single value “EUR” to make it easy for Siri just to extract the amount from the query but nothing seams to work.

I did try to add needValueRequest on the parameter but since the perform method is not triggered that part is not effective.

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img