- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
hasn' t 还没有和我一起设置。”-6ren"> hasn' t 还没有和我一起设置。”-我正在集成 Sirikit,Bill Payment 使用意图: INPayBillIntentHandling(最近在 iOS 10.3+ 中发布,2017 年 3 月 27 日)。 Apple 文-6ren">
我正在集成 Sirikit,Bill Payment 使用意图:
INPayBillIntentHandling
(最近在 iOS 10.3+ 中发布,2017 年 3 月 27 日)。
Apple 文档是 here .
Note: I'm using Obj-C Language, XCode 8.3, Device iPhone 6S with iOS 10.3 & Demo Project iOS Deployment target is iOS 10.3 AND also enabled the Siri when asked the permission for the first time and also verified that In Settings, Siri is enabled.
当我在设备上启动该应用并说“使用 DemoApp 支付账单”时,Siri 说“我希望我可以,但 DemoApp 还没有为我设置”
请帮帮我。提前致谢!
到目前为止,我做了以下步骤:
1) 创建一个 Demo Xcode 工程
2) 在 Main App Capabilities 中,启用 Siri。
3) 使用
添加了 Sirikit 扩展File -> New -> Add Target -> Intent Extension -> Next ->Add ProductName and say Finish
Note: I've disabled the Sirikit UI Extension.
4) 在 Main AppDelegate 中添加了以下内容:
#import <Intents/Intents.h>
[INPreferences requestSiriAuthorization:^(INSiriAuthorizationStatus status) {
NSLog(@"Siri Authorization status...%ld", status);
}];
5) 在 Main app Info.plist 中,添加带有使用说明的键 NSSiriUsageDescription
6) IntentExtension,Info.plist,NSExtension->IntentsSupported->added key INPayBillIntent
7) 在 IntentHandler.m 中,添加了 INPayBillIntentHandling 的所有委托(delegate)方法
@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")
您使用的货币格式不正确,导致 Siri 抛出此消息。
关于ios - SiriKit INPayBillIntentHandling - Siri 说, "I wish I could, but <App> hasn' t 还没有和我一起设置。”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43066231/
我是一名优秀的程序员,十分优秀!