0

I am trying to use sirikit to return a bill that i have stored on firebase. It is not returning the bill that it finds. This is my handle function. I am using getBills function to get my bills from the database:

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))
            }
    }

1 Answers1

0

Your INSearchForBillsIntentResponse is initiated with "failure" on both conditions. You don't have a success code - This could cause Siri not to return the bill. You also need to uncomment the bills assignment to the response.

I've had some issues with the Bills features as well at first, but it looks like most of the bugs for this are fixed with iOS 10.3 beta 4 (Though the SearchForBills UI is not that great).

zaltzy
  • 127
  • 5