How to use the react-native-permissions.check 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 goodatlas / react-native-audio-record / Example / App1.js View on Github external
checkPermission = async () => {
    const p = await Permissions.check('microphone');
    console.log('permission check', p);
    if (p === 'authorized') return;
    return this.requestPermission();
  };
github berty / berty / js / packages / components / chat / file-uploads / AddFileMenu.tsx View on Github external
onPress: async () => {
				setActiveTab(TabItems.Gallery)
				if (Platform.OS === 'ios') {
					try {
						const status = await check(PERMISSIONS.IOS.PHOTO_LIBRARY)
						if (status !== RESULTS.GRANTED) {
							try {
								const status = await request(PERMISSIONS.IOS.PHOTO_LIBRARY)
								if (status !== RESULTS.GRANTED) {
									setSecurityAccessVisibility(true)
									return
								}
							} catch (err) {
								console.log(err)
							}
						}
					} catch (err) {
						console.log(err)
					}
				}
			},
github goodatlas / react-native-audio-record / Example / App3.js View on Github external
checkPermission = async () => {
    const p = await Permissions.check('microphone');
    console.log('permission check', p);
    if (p === 'authorized') return;
    return this.requestPermission();
  };
github react-native-community / react-native-permissions / example / App.tsx View on Github external
    Promise.all(PERMISSIONS_VALUES.map(_ => RNPermissions.check(_)))
      .then(statuses => this.setState({statuses}))
github guardian / editions / projects / Mallard / src / helpers / location-permission.ts View on Github external
const resolveLocationPermissionStatus = () => {
        if (promise) return promise
        promise = check(LOCATION_PERMISSION)
        return promise
    }
github uport-project / uport-mobile / lib / screens / Scanner.tsx View on Github external
async componentDidAppear() {
    this.toggleScannerMode(true)

    let status = await Permissions.check('camera')

    if (status === 'undetermined') {
      status = await Permissions.request('camera')
    }

    this.setState({ ...this.state, hasPermission: status === 'authorized' })
  }
github RobertSasak / react-native-openalpr / example / App.js View on Github external
async checkPermission() {
    switch (await check(cameraPermission)) {
      case RESULTS.UNAVAILABLE:
        this.setState({
          error:
            'This feature is not available (on this device / in this context)',
        })
        break
      case RESULTS.DENIED:
        this.requestPermission()
        break
      case RESULTS.GRANTED:
        this.setState({
          showCamera: true,
        })
        break
      case RESULTS.BLOCKED:
        this.setState({
github goldennetwork / golden-wallet-react-native / app / modules / ScanQRCode / index.js View on Github external
requestPhotoPermission(callback = () => { }) {
    NavStore.preventOpenUnlockScreen = true
    Permissions.check('photo').then((response) => {
      if (response != 'authorized') {
        Permissions.request('photo').then((res) => {
          if (res == 'authorized') {
            callback()
          }
        })
      }
    })
  }
github mattermost / mattermost-mobile / app / components / channel_keyboard_accessory / recorder / recorder.js View on Github external
requestPermissions = async () => {
        const {formatMessage} = this.context.intl;
        let permissionRequest;
        const hasMicPermissions = await Permissions.check('microphone');

        switch (hasMicPermissions) {
        case PermissionTypes.UNDETERMINED:
            permissionRequest = await Permissions.request('microphone');
            return {
                hasPermission: permissionRequest === PermissionTypes.AUTHORIZED,
                requested: true,
            };
        case PermissionTypes.DENIED: {
            const canOpenSettings = await Permissions.canOpenSettings();
            let grantOption = null;
            if (canOpenSettings) {
                grantOption = {
                    text: formatMessage({
                        id: 'mobile.permission_denied_retry',
                        defaultMessage: 'Settings',