我正在尝试使用sirikit返回我存储在Firebase上的账单。它没有退还找到的账单。这是我的句柄功能。我正在使用getBills函数从数据库中获取帐单:
func handle(searchForBills intent: INSearchForBillsIntent, completion: @escaping (INSearchForBillsIntentResponse) -> Void) {
var arrayOfBills: [INBillDetails] = []
APIManager.getBills { (success, bills) in
if(success) {
for bill in bills {
if (bill.type == intent.billType.rawValue) {
var nickname: INSpeakableString = INSpeakableString(identifier: bill.billPayeeNickName, spokenPhrase: bill.billPayeeNickName, pronunciationHint: bill.billPayeeNickName)
var organizationalName: INSpeakableString = INSpeakableString(identifier: bill.billPayeeOrganzationalName, spokenPhrase: bill.billPayeeOrganzationalName, pronunciationHint: bill.billPayeeOrganzationalName)
var billPayee: INBillPayee = INBillPayee(nickname: nickname, number: bill.billPayeeAccountNumber, organizationName: organizationalName)!
var nsDecimalTotal: NSDecimalNumber = NSDecimalNumber(string: bill.total)
var amountDueInCurrency: INCurrencyAmount = INCurrencyAmount(amount: nsDecimalTotal, currencyCode: "$")
var dateC: DateComponents = DateComponents(calendar: Calendar.current , timeZone: TimeZone.current, era: 1, year: 2017, month: 5, day: 23, hour: 2, minute: 2, second: 2, nanosecond: 2, weekday: 3, weekdayOrdinal: 3, quarter: 3, weekOfMonth: 23, weekOfYear: 33, yearForWeekOfYear: 44)
var billToReturn = INBillDetails(billType: INBillType(rawValue: bill.type)!, paymentStatus: INPaymentStatus(rawValue: bill.status)!, billPayee: billPayee, amountDue: amountDueInCurrency, minimumDue: amountDueInCurrency, lateFee: amountDueInCurrency, dueDate: dateC, paymentDate: dateC)
arrayOfBills.append(billToReturn!)
}
}
print("success")
var response = INSearchForBillsIntentResponse(code: .failure, userActivity: nil)
//response.bills = arrayOfBills
completion(response)
}
else {
print("failed")
completion(INSearchForBillsIntentResponse(code: .failure, userActivity: nil))
}
}
最佳答案
在两种情况下,您的INSearchForBillsIntentResponse均以“失败”启动。您没有成功代码-这可能导致Siri不退还账单。
您还需要取消注释分配给响应的注释。
起初,我还遇到了Bills功能的问题,但似乎大多数错误已在iOS 10.3 beta 4中修复(尽管SearchForBills UI并不是很好)。
关于ios - SIRIKIT不退还账单,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42563589/