我正在尝试使用 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))
}
}