You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { Alert, Linking, NativeModules } from 'react-native';
  2. import { Platform } from '../../base/react';
  3. /**
  4. * Shows an alert panel which tells the user they have to manually grant some
  5. * permissions by opening Settings. A button which opens Settings is provided.
  6. *
  7. * FIXME: translate.
  8. *
  9. * @param {string} trackType - Type of track that failed with a permission
  10. * error.
  11. * @returns {void}
  12. */
  13. export function alertPermissionErrorWithSettings(trackType) {
  14. const type = trackType === 'video' ? 'Camera' : 'Microphone';
  15. Alert.alert(
  16. 'Permissions Error',
  17. `${type} permission is required, please enable it in Settings.`,
  18. [
  19. { text: 'Cancel' },
  20. {
  21. onPress: _openSettings,
  22. text: 'Settings'
  23. }
  24. ],
  25. { cancelable: false });
  26. }
  27. /**
  28. * Opens the settings panel for the current platform.
  29. *
  30. * @private
  31. * @returns {void}
  32. */
  33. function _openSettings() {
  34. switch (Platform.OS) {
  35. case 'android':
  36. NativeModules.AndroidSettings.open();
  37. break;
  38. case 'ios':
  39. Linking.openURL('app-settings:');
  40. break;
  41. }
  42. }