JLChen
2021-11-29 2e82c7f03b0833e3a149d02453d66d8db133b2ce
HDLSceneSiriDemo/HDLSceneSiri/HDLSceneHandler.m
@@ -17,6 +17,8 @@
// 建议:只用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);
@@ -24,10 +26,23 @@
- (void)handleHDLRunScene:(nonnull HDLRunSceneIntent *)intent completion:(nonnull void (^)(HDLRunSceneIntentResponse * _Nonnull))completion {
    NSLog(@"HDL handleRunScene");
    NSString *text = @"执行成功";
    NSData *jsonData = [intent.controlJSONStr dataUsingEncoding:NSUTF8StringEncoding];
    NSError *error;
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
    if (error) {
      //解析出错
    }
    NSLog(@"dic :%@",dic);
    text = [NSString stringWithFormat:@"%@ %@",text,intent.controlJSONStr];
    //执行成功
    HDLRunSceneIntentResponse *rsp = [[HDLRunSceneIntentResponse alloc] initWithCode:HDLRunSceneIntentResponseCodeSuccess userActivity:nil];
    rsp.sceneName = intent.sceneName;
    rsp.successMessage = @"执行成功";
    rsp.controlName = intent.controlName;
    rsp.successMessage = text;
    completion(rsp);
    
}