Browse Source

Adding iOS camera permissions on app.json

master
Daniel D'Angelo Resende Barros 4 years ago
parent
commit
ab593327a5
  1. 17
      src/app.json
  2. 10
      src/app/hooks/useLocation.js

17
src/app.json

@ -1,7 +1,7 @@
{
"expo": {
"name": "src",
"slug": "src",
"name": "wpd-mobileapp",
"slug": "wpd-mobileapp",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./app/assets/icon.png",
@ -13,9 +13,15 @@
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
"supportsTablet": true,
"infoPlist": {
"NSCameraUsageDescription": "Enable Camera Acess so that you can record Videos",
"NSPhotoLibraryUsageDescription": "Enable Camera Roll Access so that you can select Other Videos from Camera Roll"
}
},
"android": {
"adaptiveIcon": {
@ -25,6 +31,7 @@
},
"web": {
"favicon": "./app/assets/favicon.png"
}
},
"description": ""
}
}

10
src/app/hooks/useLocation.js

@ -1,20 +1,22 @@
import { useEffect, useState } from "react";
import * as Location from "expo-location";
export default function useLocation(
defaultLocation = { longitude: 0.0, latitude: 0.0 }
) {
export default function useLocation(defaultLocation = { longitude: 0.0, latitude: 0.0 }) {
const [location, setLocation] = useState(defaultLocation);
const getLocation = async () => {
try {
const { granted } = await Location.requestPermissionsAsync();
if (!granted) return;
const {
coords: { latitude, longitude },
} = await Location.getLastKnownPositionAsync();
setLocation({ latitude, longitude });
} catch (error) {
}
catch (error) {
console.log(error);
}
};

Loading…
Cancel
Save