From eed77b91d4d10dece7c53a81eb92b8ac94cc1f77 Mon Sep 17 00:00:00 2001 From: ankit-thanekar007 Date: Thu, 25 Feb 2021 17:43:13 -0800 Subject: Request-Contacts updated permission request code --- src/routes/main/MainStackScreen.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/routes') diff --git a/src/routes/main/MainStackScreen.tsx b/src/routes/main/MainStackScreen.tsx index 5b3f1178..acf0cd28 100644 --- a/src/routes/main/MainStackScreen.tsx +++ b/src/routes/main/MainStackScreen.tsx @@ -1,7 +1,7 @@ import AsyncStorage from '@react-native-community/async-storage'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationOptions} from '@react-navigation/stack'; -import React, {useState} from 'react'; +import React, {useEffect, useState} from 'react'; import {StyleSheet, Text} from 'react-native'; import {normalize} from 'react-native-elements'; import BackIcon from '../../assets/icons/back-arrow.svg'; @@ -51,20 +51,20 @@ const MainStackScreen: React.FC = ({route}) => { const isNotificationsTab = screenType === ScreenType.Notifications; const isSuggestedPeopleTab = screenType === ScreenType.SuggestedPeople; const [respondedToAccessContacts, setRespondedToAccessContacts] = useState( - 'false', + 'true', ); const loadResponseToAccessContacts = () => { - try { - AsyncStorage.getItem('respondedToAccessContacts').then((value) => { + AsyncStorage.getItem('respondedToAccessContacts') + .then((value) => { setRespondedToAccessContacts(value ? value : 'false'); + }) + .catch((error) => { + console.log('Something went wrong', error); + setRespondedToAccessContacts('true'); }); - } catch (err) { - console.log( - 'Unable to check and request permission to get access to user contacts', - ); - } }; + loadResponseToAccessContacts(); const initialRouteName = (() => { -- cgit v1.2.3-70-g09d2