Skip to content

Commit e7f0bc4

Browse files
author
spoeck
committed
feat: add contexts functionality for ios
1 parent 3ab5b08 commit e7f0bc4

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

index.ios.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,18 @@ class ApiAi {
5151
SpeechToText.finishRecognition();
5252
}
5353

54-
requestQuery(query: String, onResult: ()=>{}, onError: ()=>{}) {
55-
this.client.textRequest(query).then(res=>onResult(res)).catch(err=>onError(err));
56-
}
54+
setContexts(contexts) {
55+
this.contexts = contexts;
56+
}
57+
58+
requestQuery(query: String, onResult: ()=>{}, onError: ()=>{}) {
59+
if (this.contexts) {
60+
this.client.textRequest(query, {contexts: this.contexts}).then(res=>onResult(res)).catch(err=>onError(err));
61+
this.contexts = null;
62+
} else {
63+
this.client.textRequest(query).then(res=>onResult(res)).catch(err=>onError(err));
64+
}
65+
}
5766

5867
onAudioLevel(callback) {
5968

0 commit comments

Comments
 (0)