SiriKit INPayBillIntentHandling - Siri says, "Sorry I can't, but <App> hasn't installed it with me yet."
I integrate Sirikit Billing using the intention:
INPayBillIntentHandling(which was recently released in iOS 10.3 + , March 27, 2017).
Apple documentation here .
Note. I am using Obj-C Language, Xcode 8.3, Device iPhone 6S with iOS 10.3 and a demo project. The goal of deploying iOS is iOS 10.3. And he also turned on Siri when he was asked permission for the first time, and also checked that In Settings, Siri is turned on.
When I launch the application on the device and say "Payment payment using DemoApp", Siri says: "I would like, but DemoApp has not installed it with me yet"
Please help me. Thanks at Advance!
So far I have taken the following steps:
1) Create a Demo Xcode project
2) In the "Main features of the application" section, "Siri" is included.
3) Added Sirikit extension using
File → Create → Add Target → Expand Intention → Next → Add ProductName and say Finish
Note. I disabled Sirikit UI extension.
4) The following has been added to Main AppDelegate:
#import <Intents/Intents.h>
[INPreferences requestSiriAuthorization:^(INSiriAuthorizationStatus status) {
NSLog(@"Siri Authorization status...%ld", status);
}];
5) In the main application Info.plist, a key has been added NSSiriUsageDescriptionwith a description of the use
6) In IntentExtension, Info.plist, NSExtension->IntentsSupported->added key INPayBillIntent
7) IntentHandler.m added all delegate methods for INPayBillIntentHandling
@interface IntentHandler () <INPayBillIntentHandling>
@end
@implementation IntentHandler
- (id)handlerForIntent:(INIntent *)intent {
// This is the default implementation. If you want different objects to handle different intents,
// you can override this and return the handler you want for that 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]);
}
:
INCurrencyAmount *currencyAmt = [[INCurrencyAmount alloc] initWithAmount:[NSDecimalNumber decimalNumberWithString:@"100"] currencyCode:@"784"];
INCurrencyAmount *currencyAmt = [[INCurrencyAmount alloc] initWithAmount:[NSDecimalNumber decimalNumberWithString:@"100"] currencyCode:@"USD"];
Swift 3.0
let currencyAmmount = INCurrencyAmount(amount: NSDecimalNumber(string: "100"), currencyCode: "USD")
, .