ios - SiriKit INPayBillIntentHandling - Siri says, "I wish I could, but <App> hasn't set that up with me yet." -


i'm integrating sirikit, bill payment using intent:

inpaybillintenthandling (which released in ios 10.3+, 27 mar 2017).

apple documentation here.

note: i'm using obj-c language, xcode 8.3, device iphone 6s ios 10.3 & demo project ios deployment target ios 10.3 , enabled siri when asked permission first time , verified in settings, siri enabled.

when launch app on device , "bill payment using demoapp", siri says "i wish could, demoapp hasn't set me yet"

please me. in advance!

so far did following steps:

1) create demo xcode project

2) in main app capabilities, enabled siri.

3) added sirikit extension using

file -> new -> add target -> intent extension -> next ->add productname , finish

note: i've disabled sirikit ui extension.

4) in main appdelegate added following:

#import <intents/intents.h>     [inpreferences requestsiriauthorization:^(insiriauthorizationstatus status) {         nslog(@"siri authorization status...%ld", status);     }]; 

5) in main app info.plist, added key nssiriusagedescription usage description

6) in intentextension, info.plist, nsextension->intentssupported->added key inpaybillintent

7) in intenthandler.m, added delegate methods inpaybillintenthandling

@interface intenthandler () <inpaybillintenthandling>  @end  @implementation intenthandler  - (id)handlerforintent:(inintent *)intent {     // default implementation.  if want different objects handle different intents,     // can override , return handler want particular intent.      return self; }  - (void)confirmpaybill:(inpaybillintent *)intent             completion:(void (^)(inpaybillintentresponse *response))completion ns_swift_name(confirm(paybill:completion:)) {     nslog(@"\n%s", __func__);     inpaybillintentresponse *response = [[inpaybillintentresponse alloc] initwithcode:inpaybillintentresponsecodesuccess useractivity:nil];     completion(response); } - (void)handlepaybill:(inpaybillintent *)intent           completion:(void (^)(inpaybillintentresponse *response))completion ns_swift_name(handle(paybill:completion:)) {     nslog(@"\n%s", __func__);     nsuseractivity *useractivity = [[nsuseractivity alloc] initwithactivitytype:nsstringfromclass([inpaybillintent class])];      inpaybillintentresponse *response = [[inpaybillintentresponse alloc] initwithcode:inpaybillintentresponsecodeready useractivity:useractivity];     completion(response);  } - (void)resolvebillpayeeforpaybill:(inpaybillintent *)intent                     withcompletion:(void (^)(inbillpayeeresolutionresult *resolutionresult))completion ns_swift_name(resolvebillpayee(forpaybill:with:)) {     nslog(@"\n%s", __func__);      inspeakablestring *speakablestr = [[inspeakablestring alloc] initwithidentifier:@"xyz bill" spokenphrase:@"xyz bill" pronunciationhint:@"xyz bill"];     inspeakablestring *speakablestr1 = [[inspeakablestring alloc] initwithidentifier:@"xyz bill payments" spokenphrase:@"xyz payments" pronunciationhint:@"xyz bills"];      inbillpayee *billpayee = [[inbillpayee alloc] initwithnickname:speakablestr number:@"10112122112" organizationname:speakablestr1];      inbillpayeeresolutionresult *finalresult = [inbillpayeeresolutionresult successwithresolvedbillpayee:billpayee];      completion(finalresult); } - (void)resolvefromaccountforpaybill:(inpaybillintent *)intent                       withcompletion:(void (^)(inpaymentaccountresolutionresult *resolutionresult))completion ns_swift_name(resolvefromaccount(forpaybill:with:)) {     nslog(@"\n%s", __func__);     inspeakablestring *speakablestr2 = [[inspeakablestring alloc] initwithidentifier:@"john.smith" spokenphrase:@"john.smith" pronunciationhint:@"john.smith"];     inspeakablestring *speakablestr3 = [[inspeakablestring alloc] initwithidentifier:@"" spokenphrase:@"" pronunciationhint:@"organisation"];      inpaymentaccount *fromaccount = [[inpaymentaccount alloc] initwithnickname:speakablestr2 number:@"10112122112" accounttype:inaccounttypecredit organizationname:speakablestr3];       inpaymentaccountresolutionresult *finalresult = [inpaymentaccountresolutionresult successwithresolvedpaymentaccount:fromaccount];      completion(finalresult);  } - (void)resolvetransactionamountforpaybill:(inpaybillintent *)intent                             withcompletion:(void (^)(inpaymentamountresolutionresult *resolutionresult))completion ns_swift_name(resolvetransactionamount(forpaybill:with:)) {     nslog(@"\n%s", __func__);      incurrencyamount *currencyamt = [[incurrencyamount alloc] initwithamount:[nsdecimalnumber decimalnumberwithstring:@"100"] currencycode:@"784"];      inpaymentamount *transactionamt = [[inpaymentamount alloc] initwithamounttype:inamounttypeamountdue amount:currencyamt];      inpaymentamountresolutionresult *finalresult = [inpaymentamountresolutionresult successwithresolvedpaymentamount:transactionamt];      completion(finalresult);  } - (void)resolvetransactionscheduleddateforpaybill:(inpaybillintent *)intent                                   withcompletion:(void (^)(indatecomponentsrangeresolutionresult *resolutionresult))completion ns_swift_name(resolvetransactionscheduleddate(forpaybill:with:)) {      completion([indatecomponentsrangeresolutionresult notrequired]);  } - (void)resolvetransactionnoteforpaybill:(inpaybillintent *)intent                           withcompletion:(void (^)(instringresolutionresult *resolutionresult))completion ns_swift_name(resolvetransactionnote(forpaybill:with:)) {     nslog(@"\n%s", __func__);     instringresolutionresult *finalresult = [instringresolutionresult successwithresolvedstring:@"bill payment"];      completion(finalresult); } - (void)resolvebilltypeforpaybill:(inpaybillintent *)intent                   withcompletion:(void (^)(inbilltyperesolutionresult *resolutionresult))completion ns_swift_name(resolvebilltype(forpaybill:with:)) {     nslog(@"\n%s", __func__);     inbilltyperesolutionresult *finalresult = [inbilltyperesolutionresult successwithresolvedvalue:inbilltypeelectricity];      completion(finalresult);  } - (void)resolveduedateforpaybill:(inpaybillintent *)intent                   withcompletion:(void (^)(indatecomponentsrangeresolutionresult *resolutionresult))completion ns_swift_name(resolveduedate(forpaybill:with:)) {     nslog(@"%s", __func__);     completion([indatecomponentsrangeresolutionresult notrequired]); } 

i found problem, , found on following line:

incurrencyamount *currencyamt = [[incurrencyamount alloc] initwithamount:[nsdecimalnumber decimalnumberwithstring:@"100"] currencycode:@"784"]; 

to

incurrencyamount *currencyamt = [[incurrencyamount alloc] initwithamount:[nsdecimalnumber decimalnumberwithstring:@"100"] currencycode:@"usd"];  

swift 3.0

let currencyammount = incurrencyamount(amount: nsdecimalnumber(string: "100"), currencycode: "usd") 

you using incorrect currency format causes siri throw message.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -