How to use the react-native-permissions.RESULTS.GRANTED 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 berty / berty / js / packages / components / settings / Bluetooth.tsx View on Github external
Platform.OS === 'ios'
			? PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL
			: PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION
	try {
		let result = await request(permission)
		switch (result) {
			case RESULTS.UNAVAILABLE:
				console.log('Bluetooth is not available (on this device / in this context)')
				break
			case RESULTS.DENIED:
				console.log('The Bluetooth permission has not been requested / is denied but requestable')
				break
			case RESULTS.LIMITED:
				console.log('The Bluetooth permission is limited: some actions are possible')
				break
			case RESULTS.GRANTED:
				console.log('The Bluetooth permission is granted')
				return true
			case RESULTS.BLOCKED:
				console.log('The Bluetooth permission is denied and not requestable anymore')
				break
		}
	} catch (error) {
		console.log('The Bluetooth permission request failed: ', error)
	}
	return false
}
github berty / berty / js / packages / components / chat / record / RecordComponent.tsx View on Github external
const acquireMicPerm = async (): Promise => {
	try {
		const status = await check(
			Platform.OS === 'ios' ? PERMISSIONS.IOS.MICROPHONE : PERMISSIONS.ANDROID.RECORD_AUDIO,
		)
		if (status === RESULTS.GRANTED) {
			return MicPermStatus.GRANTED
		}

		try {
			const status = await request(
				Platform.OS === 'ios' ? PERMISSIONS.IOS.MICROPHONE : PERMISSIONS.ANDROID.RECORD_AUDIO,
			)

			if (status === RESULTS.GRANTED) {
				return MicPermStatus.NEWLY_GRANTED
			}

			return MicPermStatus.DENIED
		} catch (err) {
			console.log(err)
		}
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 guardian / editions / projects / Mallard / src / screens / weather-geolocation-consent-screen.tsx View on Github external
[
                    {
                        text: 'OK',
                        onPress: () => {
                            Linking.openSettings()
                        },
                    },
                ],
            )
            return
        }
        if (result === RESULTS.UNAVAILABLE) {
            showIsDisabledAlert()
            return
        }
        if (result === RESULTS.GRANTED) {
            try {
                await getGeolocation()
            } catch (error) {
                showIsDisabledAlert()
                return
            }
            navigation.dismiss()
        }
    }
    const onHidePress = () => {
github berty / berty / js / packages / components / main / bluetooth.ts View on Github external
export const requestBluetoothPermission = async (): Promise => {
	let permission =
		Platform.OS === 'ios'
			? PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL
			: PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION
	try {
		let result = await request(permission)
		if (result === RESULTS.GRANTED) {
			return true
		}
	} catch (err) {}
	return false
}
github berty / berty / js / packages / components / modals / WelcomeConfiguration.tsx View on Github external
onPress={async () => {
								closeModal()
								const { status } = await requestNotifications(['alert', 'badge'])
								await setPersistentOption({
									type: PersistentOptionsKeys.Configurations,
									payload: {
										...persistentOptions.configurations,
										notification: {
											...persistentOptions.configurations.notification,
											state: status === RESULTS.GRANTED ? 'added' : 'skipped',
										},
									},
								})
								await requestBluetoothAndHandleAlert()

								if (persistentOptions.preset.value === 'full-anonymity') {
									navigate.main.networkOptions()
								} else {
									navigate.onboarding.servicesAuth()
								}
							}}
						>
github RobertSasak / react-native-openalpr / example / App.js View on Github external
async requestPermission() {
    switch (await request(cameraPermission)) {
      case RESULTS.UNAVAILABLE:
        this.setState({
          error:
            'This feature is not available (on this device / in this context)',
        })
        break
      case RESULTS.DENIED:
        this.setState({
          error: 'The permission has been denied',
        })
        break
      case RESULTS.GRANTED:
        this.setState({
          showCamera: true,
        })
        break
      case RESULTS.BLOCKED:
        this.setState({
          error: 'The permission is denied and not requestable anymore',
        })
        break
    }
  }
github react-native-community / react-native-permissions / example / App.tsx View on Github external
function getSettingString(setting: boolean | undefined) {
  return setting
    ? RESULTS.GRANTED
    : setting === false
    ? RESULTS.DENIED
    : RESULTS.UNAVAILABLE;
}
github moaazsidat / react-native-qrcode-scanner / index.js View on Github external
request(PERMISSIONS.IOS.CAMERA).then((cameraStatus) => {
        this.setState({
          isAuthorized: cameraStatus === RESULTS.GRANTED,
          isAuthorizationChecked: true,
        });
      });
    } else if (