How to use the expo.Permissions.getAsync function in expo

To help you get started, we’ve selected a few expo 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 BrightID / BrightID / brightID-expo / src / AppBootstrap.js View on Github external
bootstrapAsync = async () => {
    // bootstrap the application
    // async storage key 'userData' : {
    // userToken: String,
    // nameornym: String,
    // avatarUri: String
    // }

    try {
      // add user permssions
      const cam = await Permissions.getAsync(Permissions.CAMERA);
      const camr = await Permissions.getAsync(Permissions.CAMERA_ROLL);
      // console.warn(cam);
      // console.warn(camr);
      // load font
      await Font.loadAsync({
        EurostileRegular: require('../assets/fonts/EurostileRegular.ttf'),
        'ApexNew-Book': require('../assets/fonts/ApexNew-Book.otf'),
        'ApexNew-Medium': require('../assets/fonts/ApexNew-Medium.otf'),
        'ApexNew-Light': require('../assets/fonts/ApexNew-Light.otf'),
      });

      // load user data
      let userData = await AsyncStorage.getItem('userData');
      if (userData !== null) {
        userData = JSON.parse(userData);
        store.dispatch(setUpDefault(userData));
github syousif94 / frugalmaps / frugalapp / src / Permissions.js View on Github external
export async function grantCalendar() {
  const { status: askStatus } = await Permissions.getAsync(
    Permissions.CALENDAR
  );

  if (IOS && askStatus === "denied") {
    throw new Error("Permission Denied");
    // Alert.alert(
    //   "Permission Denied",
    //   "To enable calendar access, tap Open Settings and then toggle the Calendar switch.",
    //   [
    //     { text: "Cancel", style: "cancel" },
    //     {
    //       text: "Open Settings",
    //       onPress: () => {
    //         Linking.openURL("app-settings:");
    //       }
    //     }
github rotembcohen / pokerBuddyApp / UtilFunctions.js View on Github external
export async function registerForPushNotificationsAsync(user_id) {
	const { existingStatus } = await Permissions.getAsync(Permissions.NOTIFICATIONS);
	let finalStatus = existingStatus;

	// only ask if permissions have not already been determined, because
	// iOS won't necessarily prompt the user a second time.
	if (existingStatus !== 'granted') {
		// Android remote notification permissions are granted during the app
		// install, so this will only ask on iOS
		const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
		finalStatus = status;
	}

	// Stop here if the user did not grant permissions
	if (finalStatus !== 'granted') {
		return;
	}
github watanabeyu / expo-firebase-instagram / src / navigation / RootNavigation.js View on Github external
getDeviceToken = async () => {
    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') {
      return;
    }

    const deviceToken = await Notifications.getExpoPushTokenAsync();
    if (deviceToken) {
      firebase.updateUserToken(deviceToken);
    }
github calebnance / expo-spotify / src / api / functions.js View on Github external
export const cameraAccessAsync = async () => {
  // get exisiting camera permissions first
  const { status: existingStatus } = await Permissions.getAsync(
    Permissions.CAMERA
  );
  let finalStatus = existingStatus;

  // ask again to grant camera permissions (if not already allowed)
  if (existingStatus !== 'granted') {
    const { status } = await Permissions.askAsync(Permissions.CAMERA);
    finalStatus = status;
  }

  return finalStatus === 'granted';
};
github benawad / fullstack-graphql-airbnb-clone / packages / app / src / modules / shared / PictureField.tsx View on Github external
onPress = async () => {
    const { status } = await Permissions.getAsync(Permissions.CAMERA_ROLL);
    if (status !== "granted") {
      await Permissions.askAsync(Permissions.CAMERA_ROLL);
    }
    const imageResult = await ImagePicker.launchImageLibraryAsync({});
    if (!imageResult.cancelled) {
      const file = new ReactNativeFile({
        uri: imageResult.uri,
        type: imageResult.type,
        name: "picture"
      });
      const {
        field: { name },
        form: { setFieldValue }
      } = this.props;
      setFieldValue(name, file);
    }
github syousif94 / frugalmaps / frugalapp / src / Notifications.js View on Github external
async function checkPermission() {
  const { status: askStatus } = await Permissions.getAsync(
    Permissions.NOTIFICATIONS
  );

  if (askStatus === "denied") {
    Alert.alert(
      "Permission Denied",
      "To enable notifications, tap Open Settings and then toggle the Notifications switch.",
      [
        { text: "Cancel", style: "cancel" },
        {
          text: "Open Settings",
          onPress: () => {
            Linking.openURL("app-settings:");
          }
        }
      ]