Warm tip: This article is reproduced from serverfault.com, please click

其他-iOS:如何为无输入操作快捷方式定义意图文件

(其他 - iOS: How to define the intent file for no input action shortcuts)

发布于 2020-12-10 07:10:21

我希望开发人员像这样执行快捷方式操作,而房间名称是我在我的应用中编辑的,请在 此处输入图片描述

所以我这样定义意图文件

在此处输入图片说明

我的捐赠代码是这样的

    LightControlIntent *intent = [[LightControlIntent alloc] init];
    [intent setROOMNAME:@"MY BIG BIG HOUSE"];
    
    INInteraction *recation = [[INInteraction alloc] initWithIntent:intent response:nil];
    [recation donateInteractionWithCompletion:^(NSError * _Nullable error) {
        if(!error) {
            NSLog(@"donation success");
        }else {
            NSLog(@"donation fail %@",error.localizedDescription);
        }
    }];

但这不起作用,这是Xcode打印,

donation fail Cannot donate interaction with intent that has no valid shortcut types: <INInteraction: 0x6000013bc9c0> {
    intent = <INIntent: 0x6000019b3f00> {
    };
    dateInterval = <_NSConcreteDateInterval: 0x6000037ede60> (Start Date) 2020-12-10 06:49:53 +0000 + (Duration) 0.000000 seconds = (End Date) 2020-12-10 06:49:53 +0000;
    intentResponse = <null>;
    groupIdentifier = <null>;
    intentHandlingStatus = Unspecified;
    identifier = 4FEC8BA0-6E7E-4605-8246-7B06833A7863;
    direction = Unspecified;
} for intent <LightControlIntent: 0x6000019a2880> {
    rOOMNAME = MY BIG BIG HOUSE;
}

我尝试在“建议”部分中定义“无参数”,那么我可以成功捐赠,但无法获得ROOMNAME。请帮助!

Questioner
Jackson
Viewed
0
Jackson 2021-01-21 10:26:12

我已经弄清楚了,只需将你的参数更改为小写字母,然后它就可以了