Skip to content

Commit 737cd3e

Browse files
committed
Update Readme for 1.2.0
1 parent 59342fe commit 737cd3e

File tree

1 file changed

+62
-1
lines changed

1 file changed

+62
-1
lines changed

README.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,65 @@ DeviceEventEmitter.addListener('Proximity', function (data) {
141141

142142
```
143143

144+
## About Permission:
145+
146+
147+
since version 1.2.0, two functions and a property were added:
148+
149+
```javascript
150+
// --- function
151+
async checkRecordPermission() // return promise
152+
async requestRecordPermission() // return promise
153+
154+
// --- property
155+
recordPermission = 'unknow' or 'granted' or 'denied', default is 'unknow'
156+
```
157+
158+
After incall-manager initialized, it will check current state of record permission and set to `recordPermission` property.
159+
so you can just write below code in your `ComponentDidMount` like:
160+
161+
```javascript
162+
if (InCallManager.recordPermission !== 'granted') {
163+
InCallManager.requestRecordPermission()
164+
.then((requestedRecordPermissionResult) => {
165+
console.log("InCallManager.requestRecordPermission() requestedRecordPermissionResult: ", requestedRecordPermissionResult);
166+
})
167+
.catch((err) => {
168+
console.log("InCallManager.requestRecordPermission() catch: ", err);
169+
});
170+
}
171+
```
172+
173+
**NOTE for android:**
174+
175+
React Native does not officially support api 23 currently ( it is on api 22 now. see: [RN known issues](https://facebook.github.io/react-native/docs/known-issues.html#android-m-permissions)) and android supports request permission at runtime since api 23, so it will always return 'granted' immediately after calling `checkRecordPermission()` or `requestRecordPermission()`.
176+
177+
If you really need the functionality, you can do the following to make them work but at your own risk:
178+
( I've tested it though, but who knows :) )
179+
180+
Step 1: change your `targetSdkVersion` to 23 in `$your_project/android/app/build.gradle`
181+
Step 2: override `onRequestPermissionsResult` in your `MainActivity.java` like:
182+
183+
```
184+
@Override
185+
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
186+
InCallManagerPackage.onRequestPermissionsResult(requestCode, permissions, grantResults);
187+
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
188+
}
189+
```
190+
191+
then you can test it on android 6 now.
192+
193+
**Another thing you should know is:**
194+
195+
If you change targetSdkVersion to 23, the `red box` which React Native used to display errors in development mode requires permission `Draw Over Other Apps`.
196+
So in **development mode**, you should manually grant permission in `app settings` on your device or declare `android.permission.SYSTEM_ALERT_WINDOW` in your manifest.
197+
You don't have to do this in **release mode** since there are no red box.
198+
199+
200+
checkout this awesome project: [react-native-android-permissions](https://github.com/lucasferreira/react-native-android-permissions) by @lucasferreira for more information.
201+
202+
144203
## Automatic Basic Behavior:
145204

146205
**on start:**
@@ -176,6 +235,8 @@ note: ios only supports `auto` currently.
176235
| setSpeakerphoneOn(`enable: ?boolean`) | :smile: | :rage: | toggle speaker ON/OFF once. but not force</br>default: false |
177236
| setForceSpeakerphoneOn(`flag: ?boolean`) | :smile: | :smile: | true -> force speaker on</br> false -> force speaker off</br> null -> use default behavior according to media type</br>default: null |
178237
| setMicrophoneMute(`enable: ?boolean`) | :smile: | :rage: | mute/unmute micophone</br>default: false |
238+
| async checkRecordPermission() | :smile: | :smile: | check record permission without promt. return Promise. see **about permission** section above |
239+
| async requestRecordPermission() | :smile: | :smile: | request record permission to user. return Promise. see **about permission** section above |
179240

180241
**Events**
181242

@@ -192,7 +253,7 @@ be care when customize your own behavior**
192253

193254
## LICENSE:
194255

195-
**[ICS License](https://opensource.org/licenses/ISC)** ( functionality equivalent to **MIT License** )
256+
**[ISC License](https://opensource.org/licenses/ISC)** ( functionality equivalent to **MIT License** )
196257

197258
## Contributing:
198259

0 commit comments

Comments
 (0)