From ab593327a556921dca8d54cc69259970523a9cf0 Mon Sep 17 00:00:00 2001 From: Daniel D'Angelo Resende Barros Date: Wed, 6 Jan 2021 11:29:18 -0300 Subject: [PATCH] Adding iOS camera permissions on app.json --- src/app.json | 17 ++++++++++++----- src/app/hooks/useLocation.js | 10 ++++++---- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/app.json b/src/app.json index 9ab992d..08a6fa5 100644 --- a/src/app.json +++ b/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": "" } } diff --git a/src/app/hooks/useLocation.js b/src/app/hooks/useLocation.js index 0101e23..c9a7318 100644 --- a/src/app/hooks/useLocation.js +++ b/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); } };