SiriKit INPayBillIntentHandling - Siri 说,“我希望我能,但是 <App>还没有和我设置好." [英] SiriKit INPayBillIntentHandling - Siri says, "I wish I could, but <App> hasn't set that up with me yet."

查看:27
本文介绍了SiriKit INPayBillIntentHandling - Siri 说,“我希望我能,但是 <App>还没有和我设置好."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Intent 集成 Sirikit、Bill Payment:

I'm integrating Sirikit, Bill Payment using the intent:

INPayBillIntentHandling(最近在 iOS 10.3+ 中发布,2017 年 3 月 27 日).

INPayBillIntentHandling (which was released recently in iOS 10.3+, 27 Mar 2017).

Apple 文档位于此处.

Apple Documentation is here.

注意:我使用的是 Obj-C 语言、XCode 8.3、设备 iPhone 6S 和 iOS 10.3 &演示项目 iOS 部署目标是 iOS 10.3 并且还启用了 Siri当第一次询问权限时,也验证了在设置,Siri 已启用.

当我在设备上启动应用程序并说使用 DemoApp 支付账单"时,Siri 说我希望我可以,但 DemoApp 还没有为我设置"

When I launch the app on device and say "Bill Payment using DemoApp", Siri says "I wish I could, but DemoApp hasn't set that up with me yet"

请帮帮我.提前致谢!

到目前为止,我做了以下步骤:

So far I did the following steps:

1) 创建一个 Xcode 演示项目

1) Create a Demo Xcode project

2) 在 Main App Capabilities 中,启用 Siri.

2) In Main App Capabilities, Enabled Siri.

3) 使用

文件 -> 新建 -> 添加目标 -> 意图扩展 -> 下一步 -> 添加产品名称并说完成

File -> New -> Add Target -> Intent Extension -> Next ->Add ProductName and say Finish

注意:我已禁用 Sirikit UI 扩展.

Note: I've disabled the Sirikit UI Extension.

4) 在 Main AppDelegate 中添加以下内容:

4) In Main AppDelegate added the following:

#import <Intents/Intents.h>
    [INPreferences requestSiriAuthorization:^(INSiriAuthorizationStatus status) {
        NSLog(@"Siri Authorization status...%ld", status);
    }];

5) 在 Main app Info.plist 中,添加键 NSSiriUsageDescription 和使用说明

5) In Main app Info.plist, added key NSSiriUsageDescription with usage description

6) 在 IntentExtension, Info.plist 中,NSExtension->IntentsSupported->添加密钥 INPayBillIntent

6) In IntentExtension, Info.plist, NSExtension->IntentsSupported->added key INPayBillIntent

7) 在 IntentHandler.m 中,添加了 INPayBillIntentHandling 的所有委托方法

7) In IntentHandler.m, added all the 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]);
}

推荐答案

我发现了问题,在下面一行找到:

I found the problem, and is found on the following line:

INCurrencyAmount *currencyAmt = [[INCurrencyAmount alloc] initWithAmount:[NSDecimalNumber decimalNumberWithString:@"100"] currencyCode:@"784"];

INCurrencyAmount *currencyAmt = [[INCurrencyAmount alloc] initWithAmount:[NSDecimalNumber decimalNumberWithString:@"100"] currencyCode:@"USD"]; 

斯威夫特 3.0

let currencyAmmount = INCurrencyAmount(amount: NSDecimalNumber(string: "100"), currencyCode: "USD")

您使用的货币格式不正确,导致 Siri 抛出此消息.

You are using an incorrect currency format with causes Siri to throw this message.

这篇关于SiriKit INPayBillIntentHandling - Siri 说,“我希望我能,但是 &lt;App&gt;还没有和我设置好."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆