How to use the react-native-permissions.requestPermission function in react-native-permissions

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 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 / js / util / geo.js View on Github external
export async function getPosition() {
//  Permissions.openSettings();
  if (Platform.OS === 'ios') {
    const status = await Permissions.requestPermission('location');
    if (status !== 'authorized') {
      // No location permission. Let's ignore it for now since the app will work fine
      // But if we ever change our mind, we can prompt and run:
      // Permissions.openSettings();
      throw new Error('No location permissions');
    }
    // Otherwise have authorized permissions now, let's get their location!
  }
  return await getCurrentPosition();
}
github mikelambert / dancedeets-monorepo / mobile / js / util / geo.js View on Github external
export async function getPosition() {
  //  Permissions.openSettings();
  if (Platform.OS === 'ios') {
    const status = await Permissions.requestPermission('location');
    if (status !== 'authorized') {
      // No location permission. Let's ignore it for now since the app will work fine
      // But if we ever change our mind, we can prompt and run:
      // Permissions.openSettings();
      throw new Error('No location permissions');
    }
    // Otherwise have authorized permissions now, let's get their location!
  }
  return await getCurrentPosition();
}
github UCSD / campus-mobile / app / containers / geoLocationContainer.js View on Github external
getPermission() {
		Permissions.requestPermission('location')
		.then(response => {
			// dispatch response
			this.props.dispatch(setPermission(response));

			// if authorized, act
			if (response === 'authorized') {
				this.startLocationWatch();
			}
		})
		.catch((error) => {
			logger.log('Error requesting Permission: ' + error);
			return null;
		});
	},
github ugiacoman / react-native-broadcast / index.ios.js View on Github external
_requestCamera() {
    Permissions.requestPermission('camera')
      .then(response => {
        //returns once the user has chosen to 'allow' or to 'not allow' access
        //response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
        console.log("camera response after req", response)
      });
  }
  _requestMicrophone() {
github ugiacoman / react-native-broadcast / index.ios.js View on Github external
_requestMicrophone() {
    Permissions.requestPermission('microphone')
      .then(response => {
        //returns once the user has chosen to 'allow' or to 'not allow' access
        //response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
        console.log("microphone response after req", response)
      });
  }