Skip to content

Commit

Permalink
Merge pull request #23 from hecom-rn/hanhu
Browse files Browse the repository at this point in the history
语音权限判断,增加语音权限请求逻辑
  • Loading branch information
summer88123 authored Feb 20, 2021
2 parents 8e3c943 + e4acb22 commit d5771ed
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions standard/component/BottomBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -465,29 +465,22 @@ export default class extends React.PureComponent<Props, State> {
Keyboard.dismiss();
}
if (this.isIos) {
check(PERMISSIONS.IOS.MICROPHONE).then((result: any) => {
switch (result) {
case RESULTS.UNAVAILABLE:
Toast.show(i18n.t('IMCommonNoRecordAuthority'));
break;
case RESULTS.DENIED:
Toast.show(i18n.t('IMCommonNoRecordAuthority'));
break;
case RESULTS.GRANTED:
this.setState({
showSpeech: !this.state.showSpeech,
showEmojiView: false,
showMoreBoard: false,
check(PERMISSIONS.IOS.MICROPHONE)
.then(result => result === RESULTS.GRANTED ? RESULTS.GRANTED :
request(PERMISSIONS.IOS.MICROPHONE))
.then(result => {
if (result === RESULTS.GRANTED) {
this.setState({
showSpeech: !this.state.showSpeech,
showEmojiView: false,
showMoreBoard: false,
});
break;
case RESULTS.BLOCKED:
Toast.show(i18n.t('IMCommonNoRecordAuthority'));
break;
} else if (result === RESULTS.DENIED) {
// do nothing
} else {
Toast.show(i18n.t('IMCommonNoRecordAuthority'));
}
})
.catch(() => {

});
});
} else {
PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.RECORD_AUDIO)
.then(granted => granted ? PermissionsAndroid.RESULTS.GRANTED :
Expand Down

0 comments on commit d5771ed

Please sign in to comment.