From bbc7d3b3169e145708c6646a6f4003fc2735f1fb Mon Sep 17 00:00:00 2001 From: Shravya Ramesh Date: Wed, 3 Feb 2021 10:51:11 -0800 Subject: Enabled button functionality --- src/screens/search/RequestContactsAccess.tsx | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/screens') diff --git a/src/screens/search/RequestContactsAccess.tsx b/src/screens/search/RequestContactsAccess.tsx index af511f23..c869ed1e 100644 --- a/src/screens/search/RequestContactsAccess.tsx +++ b/src/screens/search/RequestContactsAccess.tsx @@ -14,9 +14,30 @@ import {useNavigation} from '@react-navigation/native'; import {SafeAreaView} from 'react-native-safe-area-context'; import Animated from 'react-native-reanimated'; import LinearGradient from 'react-native-linear-gradient'; +import {checkPermission, requestPermission} from 'react-native-contacts'; +import AsyncStorage from '@react-native-community/async-storage'; const RequestContactsAccess: React.FC = () => { const navigation = useNavigation(); + + const handleAllowAccess = async () => { + checkPermission().then((permission) => { + if (permission === 'undefined') { + requestPermission().then((response) => { + if (response === 'authorized' || response === 'denied') { + navigation.navigate('Search'); + } + }); + } + }); + await AsyncStorage.setItem('respondedToAccessContacts', 'true'); + }; + + const handleDontAllowAccess = async () => { + await AsyncStorage.setItem('respondedToAccessContacts', 'true'); + navigation.navigate('Search'); + }; + return ( { { - console.log('Show IOS opoup'); - }} + onPress={handleAllowAccess} style={styles.allowButton}> Allow Contacts navigation.pop()}> + onPress={handleDontAllowAccess}> Don’t Allow -- cgit v1.2.3-70-g09d2