//
|
// HDLSceneHandler.m
|
// HDLSceneSiri
|
//
|
// Created by 陈嘉乐 on 2021/11/25.
|
//
|
|
#import "HDLSceneHandler.h"
|
|
@implementation HDLSceneHandler
|
|
// 该方法是在 siri 匹配到相应的 Intent 时候调用。
|
// 如果用失败的方法初始化HDLRunSceneIntentResponse,在匹siri后就会报错
|
// 不管用哪个成功的方式,只是初始化参数的值而已,都一样
|
// 此为第一道拦截,如果code设置为失败或者打开app,那就直接失败/跳走了,连展示界面的机会都没有
|
// 所以一半这里就直接返回成功,让siri继续往下走,打开界面
|
// 建议:只用reday和success 这两个code
|
- (void)confirmRunScene:(HDLRunSceneIntent *)intent completion:(void (^)(HDLRunSceneIntentResponse *response))completion NS_SWIFT_NAME(confirm(intent:completion:)){
|
|
HDLRunSceneIntentResponse *rsp = [[HDLRunSceneIntentResponse alloc] initWithCode:HDLRunSceneIntentResponseCodeInProgress userActivity:nil];
|
rsp.successMessage =@"请等待...";
|
completion(rsp);
|
}
|
|
- (void)handleHDLRunScene:(nonnull HDLRunSceneIntent *)intent completion:(nonnull void (^)(HDLRunSceneIntentResponse * _Nonnull))completion {
|
NSLog(@"HDL handleRunScene");
|
//执行成功
|
HDLRunSceneIntentResponse *rsp = [[HDLRunSceneIntentResponse alloc] initWithCode:HDLRunSceneIntentResponseCodeSuccess userActivity:nil];
|
rsp.sceneName = intent.sceneName;
|
rsp.successMessage = @"执行成功";
|
completion(rsp);
|
|
}
|
|
|
@end
|