blackuy / react-native-twilio-video-webrtc

Twilio Video (WebRTC) for React Native
https://www.twilio.com/docs/video
MIT License
608 stars 404 forks source link

Android can't connect #575

Closed hungcuongDev closed 2 years ago

hungcuongDev commented 2 years ago

Steps to reproduce

  1. config build success app on Android and IOS
  2. anything ios work okay
  3. Nothing happens when connecting

Expected behaviour

Tell us what should happen

Actual behaviour

Environment

react-native-twilio-video-webrtc

Version: master

hungcuongDev commented 2 years ago

I found the problem, the problem is in the access permission of android

henriflouquet commented 2 years ago

Hi, can you please tell what you did regarding access permission to fix it ? I have the same issue on android even though I followed the set up process carefully. Thank you

vikrambombhi commented 2 years ago

I'm having this same issue @hungcuongDev . What permission did you add?

JustinRohweller commented 2 years ago

Commenting that I literally just went into settings on my phone for the app and enabled all of the available permissions (MICROPHONE, STORAGE, CAMERA, CALENDAR). And then it worked just fine.

hungcuongDev commented 2 years ago

Before calling the connect function, use this function to check permissions

======================================================== export const checkPermissions = (callback?: any) => { const iosPermissions = [PERMISSIONS.IOS.CAMERA, PERMISSIONS.IOS.MICROPHONE]; const androidPermissions = [ PERMISSIONS.ANDROID.CAMERA, PERMISSIONS.ANDROID.RECORD_AUDIO, ]; checkMultiple( Platform.OS === 'ios' ? iosPermissions : androidPermissions, ).then(statuses => { const [CAMERA, AUDIO] = Platform.OS === 'ios' ? iosPermissions : androidPermissions; if ( statuses[CAMERA] === RESULTS.UNAVAILABLE || statuses[AUDIO] === RESULTS.UNAVAILABLE ) { Alert.alert('Error', 'Hardware to support video calls is not available'); } else if ( statuses[CAMERA] === RESULTS.BLOCKED || statuses[AUDIO] === RESULTS.BLOCKED ) { Alert.alert( 'Error', 'Permission to access hardware was blocked, please grant manually', ); } else { if ( statuses[CAMERA] === RESULTS.DENIED && statuses[AUDIO] === RESULTS.DENIED ) { requestMultiple( Platform.OS === 'ios' ? iosPermissions : androidPermissions, ).then(newStatuses => { if ( newStatuses[CAMERA] === RESULTS.GRANTED && newStatuses[AUDIO] === RESULTS.GRANTED ) { callback && callback(); } else { Alert.alert('Error', 'One of the permissions was not granted'); } }); } else if ( statuses[CAMERA] === RESULTS.DENIED || statuses[AUDIO] === RESULTS.DENIED ) { request(statuses[CAMERA] === RESULTS.DENIED ? CAMERA : AUDIO).then( result => { if (result === RESULTS.GRANTED) { callback && callback(); } else { Alert.alert('Error', 'Permission not granted'); } }, ); } else if ( statuses[CAMERA] === RESULTS.GRANTED || statuses[AUDIO] === RESULTS.GRANTED ) { callback && callback(); } } }); };