| | |
| | | // 建议:只用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"); |
| | | 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); |
| | | |
| | | } |