How to use the expo-permissions.askAsync function in expo-permissions

To help you get started, we’ve selected a few expo-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 expo / expo / apps / native-component-list / src / screens / ImagePickerScreen.tsx View on Github external
async function requestPermissionAsync(permission: Permissions.PermissionType) {
  // Image Picker doesn't need permissions in the web
  if (Platform.OS === 'web') {
    return true;
  }
  const { status } = await Permissions.askAsync(permission);
  return status === 'granted';
}
github catalinmiron / uzual-mobile / screens / habits / Habits.js View on Github external
registerForPushNotificationsAsync = async () => {
    if (Constants.isDevice) {
      const { status: existingStatus } = await Permissions.getAsync(
        Permissions.NOTIFICATIONS
      );
      let finalStatus = existingStatus;
      if (existingStatus !== 'granted') {
        const { status } = await Permissions.askAsync(
          Permissions.NOTIFICATIONS
        );
        finalStatus = status;
      }
      if (finalStatus !== 'granted') {
        alert('Failed to get push token for push notification!');
        return;
      }
      let token = await Notifications.getExpoPushTokenAsync();
      this._onSetPushToken(token);
    } else {
      // alert('Must use physical device for Push Notifications');
    }

    await scheduleMoodReminders();
  };
github SCasarotto / casarotto-chat / src / pages / Profile / Profile.js View on Github external
handleUploadImage = () => {
		Permissions.askAsync(Permissions.CAMERA_ROLL)
			.then((response) => {
				const { status } = response
				if (status === 'granted') {
					ImagePicker.launchImageLibraryAsync({
						allowsEditing: true,
						aspect: [1, 1],
						base64: true,
						quality: 0.5,
					})
						.then((response) => {
							if (!response.cancelled) {
								this.props.uploadImage(response.uri)
							}
						})
						.catch((error) => console.log(error))
				}
github expo / expo / apps / native-component-list / src / screens / NotificationScreen.tsx View on Github external
_obtainUserFacingNotifPermissionsAsync = async () => {
    let permission = await Permissions.getAsync(
      Permissions.USER_FACING_NOTIFICATIONS
    );
    if (permission.status !== 'granted') {
      permission = await Permissions.askAsync(
        Permissions.USER_FACING_NOTIFICATIONS
      );
      if (permission.status !== 'granted') {
        Alert.alert(`We don't have permission to present notifications.`);
      }
    }
    return permission;
  }
github FaridSafi / react-native-gifted-chat / example-expo / mediaUtils.js View on Github external
export default async function getPermissionAsync(permission) {
  const { status } = await Permissions.askAsync(permission)
  if (status !== 'granted') {
    const permissionName = permission.toLowerCase().replace('_', ' ')
    Alert.alert(
      'Cannot be done 😞',
      `If you would like to use this feature, you'll need to enable the ${permissionName} permission in your phone settings.`,
      [
        {
          text: "Let's go!",
          onPress: () => Linking.openURL('app-settings:'),
        },
        { text: 'Nevermind', onPress: () => {}, style: 'cancel' },
      ],
      { cancelable: true },
    )

    return false
github akveo / kittenTricks / src / containers / layouts / messaging / chat3 / chat3.container.tsx View on Github external
private onAddButtonPress = (): void => {
    Permissions.askAsync(Permissions.CAMERA_ROLL)
      .then(this.onCameraPermissionResponse);
  };
github keybase / client / shared / util / expo-image-picker.tsx View on Github external
) => (error: any): Promise => {
  if (error.code === 'E_MISSING_PERMISSION' && retryFn) {
    return Permissions.askAsync(...perms).then(retryFn)
  } else {
    throw error
  }
}