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": { "expo": {
"name": "src",
"slug": "src",
"name": "wpd-mobileapp",
"slug": "wpd-mobileapp",
"version": "1.0.0", "version": "1.0.0",
"orientation": "portrait", "orientation": "portrait",
"icon": "./app/assets/icon.png", "icon": "./app/assets/icon.png",
@ -13,9 +13,15 @@
"updates": { "updates": {
"fallbackToCacheTimeout": 0 "fallbackToCacheTimeout": 0
}, },
"assetBundlePatterns": ["**/*"],
"assetBundlePatterns": [
"**/*"
],
"ios": { "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": { "android": {
"adaptiveIcon": { "adaptiveIcon": {
@ -25,6 +31,7 @@
}, },
"web": { "web": {
"favicon": "./app/assets/favicon.png" "favicon": "./app/assets/favicon.png"
}
},
"description": ""
} }
} }

10
src/app/hooks/useLocation.js

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

Loading…
Cancel
Save