Skip to content

Commit c96cbb4

Browse files
author
spoeck
committed
doc: docs for iOS
1 parent 3e77252 commit c96cbb4

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

README.md

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ npm install --save react-native-api-ai
1818
react-native link react-native-api-ai
1919
```
2020

21+
### iOS: IMPORTANT xCode plist settings
22+
23+
Also, you need open the React Native xCode project and add two new keys into `Info.plist`
24+
Just right click on `Info.plist` -> `Open As` -> `Source Code` and paste these strings somewhere into root `<dict>` tag
25+
26+
```xml
27+
<key>NSSpeechRecognitionUsageDescription</key>
28+
<string>Your usage description here</string>
29+
<key>NSMicrophoneUsageDescription</key>
30+
<string>Your usage description here</string>
31+
```
32+
33+
Application will crash if you don't do this.
2134

2235
## Usage
2336
Import ApiAi:
@@ -48,8 +61,14 @@ Start listening with integrated speech recognition:
4861
}}
4962
/>
5063
```
64+
In iOS only you have to call `finishListening()`. Android detects the end of your speech automatically. That's the reason why didn't implemented the finish method in Android.
65+
```javascript
66+
// only for iOS
67+
ApiAi.finishListening();
68+
// after this call your callbacks from the startListening will be executed.
69+
```
5170

52-
Usage of `onListeningStarted`, `onListeningCanceled`, `onListeningFinished` and `onAudioLevel`:
71+
Only in Android we have four additional methods: `onListeningStarted`, `onListeningCanceled`, `onListeningFinished` and `onAudioLevel`. In iOS they will be never called:
5372
```javascript
5473
<Button onPress={() => {
5574

@@ -112,15 +131,16 @@ ApiAi.setConfiguration("4xxxxxxxe90xxxxxxxxc372", ApiAi.LANG_GERMAN);
112131
* LANG_UKRAINIAN
113132

114133
## Methods
115-
| name | param1 | param2 | param3 |
134+
| name | platform | param1 | param2 | param3 |
116135
| --------------------- | --------- | --------- | --------- |
117-
| `setConfiguration` | clientAccessToken: String | languageTag: String | |
118-
| `startListening` | resultCallback: (result: object)=>{} | errorCallback: (error: object)=>{} | |
119-
| `requestQuery` | query: String | resultCallback: (result: object)=>{} | errorCallback: (error: object)=>{} |
120-
| `onListeningStarted` | callback: ()=>{} | | |
121-
| `onListeningCanceled` | callback: ()=>{} || |
122-
| `onListeningFinished` | callback: ()=>{} | | |
123-
| `onAudioLevel` | callback: (level: number)=>{} || |
136+
| `setConfiguration` | both | clientAccessToken: String | languageTag: String | |
137+
| `startListening` | both | resultCallback: (result: object)=>{} | errorCallback: (error: object)=>{} | |
138+
| `finishListening` | ios | | | |
139+
| `requestQuery` | both | query: String | resultCallback: (result: object)=>{} | errorCallback: (error: object)=>{} |
140+
| `onListeningStarted` | android | callback: ()=>{} | | |
141+
| `onListeningCanceled` | android | callback: ()=>{} || |
142+
| `onListeningFinished` | android | callback: ()=>{} | | |
143+
| `onAudioLevel` | android | callback: (level: number)=>{} || |
124144

125145

126146
## Contributors

0 commit comments

Comments
 (0)