How to use react-native-permissions - 10 common examples

To help you get started, we’ve selected a few react-native-permissions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mikelambert / dancedeets-monorepo / mobile / js / api / calendar.js View on Github external
}
  }

  if (status !== 'authorized') {
    if (status === 'restricted') {
      OkAlert('Cannot Access Calendar', 'Could not access calendar.');
      return false;
    } else if (status === 'denied') {
      try {
        // TODO(localization)
        await OkCancelAlert(
          'Cannot Access Calendar',
          'Please open Settings to allow Calendar permissions.'
        );
        if (await Permissions.canOpenSettings()) {
          Permissions.openSettings();
        }
      } catch (err) {
        console.log('Canceled: Add to Calendar Permissions');
      }
    }
    return false;
  }

  const { start, end } = getStartEndTime(event);

  try {
    CalendarEventsIOS.saveEvent(event.name, {
      location: event.venue.fullAddress(),
      notes: getDescription(event),
      startDate: start.toISOString(),
      endDate: end.toISOString(),
github EdgeApp / edge-login-ui / src / web / lib / native / permissions.js View on Github external
export async function requestReadContactPermission (callback) {
  try {
    Permissions.requestPermission('contacts').then(response => {
      let granted = false
      if (response === 'authorized') {
        granted = true
      }
        // response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
      return callback(null, granted)
    })
  } catch (err) {
    console.error(err)
    callback(err, null)
  }
}
github EdgeApp / edge-login-ui / src / web / lib / native / permissions.js View on Github external
export async function requestCameraPermission (callback) {
  try {
    Permissions.requestPermission('camera').then(response => {
      let granted = false
      if (response === 'authorized') {
        granted = true
      }
        // response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
      return callback(null, granted)
    })
  } catch (err) {
    console.error(err)
    callback(err, null)
  }
}
github mikelambert / dancedeets-monorepo / mobile / js / api / calendar.js View on Github external
return false;
    }
  }

  if (status !== 'authorized') {
    if (status === 'restricted') {
      OkAlert('Cannot Access Calendar', 'Could not access calendar.');
      return false;
    } else if (status === 'denied') {
      try {
        // TODO(localization)
        await OkCancelAlert(
          'Cannot Access Calendar',
          'Please open Settings to allow Calendar permissions.'
        );
        if (await Permissions.canOpenSettings()) {
          Permissions.openSettings();
        }
      } catch (err) {
        console.log('Canceled: Add to Calendar Permissions');
      }
    }
    return false;
  }

  const { start, end } = getStartEndTime(event);

  try {
    CalendarEventsIOS.saveEvent(event.name, {
      location: event.venue.fullAddress(),
      notes: getDescription(event),
      startDate: start.toISOString(),
github EdgeApp / edge-login-ui / src / web / lib / native / permissions.js View on Github external
export async function checkReadContactPermission (callback) {
  try {
    Permissions.getPermissionStatus('contacts').then(response => {
      let granted = false
      if (response === 'authorized') {
        granted = true
      }
        // response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
      return callback(null, granted)
    })
  } catch (err) {
    console.error(err)
    callback(err, null)
  }
}
github EdgeApp / edge-login-ui / src / web / lib / native / permissions.js View on Github external
export async function checkCameraPermission (callback) {
  try {
    Permissions.getPermissionStatus('camera').then(response => {
      let granted = false
      if (response === 'authorized') {
        granted = true
      }
        // response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
      return callback(null, granted)
    })
  } catch (err) {
    console.error(err)
    callback(err, null)
  }
}
github UCSD / campus-mobile / app / containers / pushNotificationContainer.js View on Github external
getPermission = () => {
		Permissions.request('notification')
			.then((response) => {
				// if authorized, act
				if (response === 'authorized') {
					this.getNotificationToken()
				}
			})
	}
github joe307bad / points / Native.Points / app / upload / components / index.tsx View on Github external
public componentDidMount() {
        // @ts-ignore
        this.uploadPreview = this.refs.uploadPreview.refs.uploadPreviewModal;

        Permissions.request('camera');
        Permissions.request('photo');
    }
github square / react-native-square-reader-sdk / reader-sdk-react-native-quickstart / app / screens / SplashScreen.js View on Github external
window.setTimeout(async () => {
      const { navigate } = this.props.navigation;
      try {
        const permissions = await Permissions.checkMultiple(['microphone', 'location']);

        if (Platform.OS === 'ios' // Android doesn't need to handle permission explicitly
            && (permissions.microphone !== 'authorized'
              || permissions.location !== 'authorized')) {
          this.props.navigation.navigate('PermissionSettings');
          return;
        }

        const isAuthorized = await isAuthorizedAsync();
        if (!isAuthorized) {
          navigate('Auth');
          return;
        }

        // Permission has been granted (for iOS only) and readerSDK has been authorized
        this.props.navigation.navigate('Checkout');
github squatsandsciencelabs / OpenBarbellApp / app / utility / VideoPermissionsUtils.js View on Github external
return new Promise(async (resolve, reject) => {
        Permissions.checkMultiple(['camera', 'photo', 'microphone']).then(response => {
            // Response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
            const isCameraAuthorized = response.camera === 'authorized';
            const isMicrophoneAuthorized = response.microphone === 'authorized';
            const isStorageAuthorized = response.photo === 'authorized';
            if (isCameraAuthorized && isMicrophoneAuthorized && isStorageAuthorized) {
                resolve();
            } else {
                Alert.alert(
                    'Additional Permissions Required',
                    recordingPermissionsErrorMessage(isCameraAuthorized, isMicrophoneAuthorized, isStorageAuthorized),
                    [{text: 'OK'}],
                    { cancelable: false }
                );
                // TODO: should put it in the catch so can pass in state
                Analytics.logEvent('record_video_permissions_warning', {});
                reject();