aboutsummaryrefslogtreecommitdiff
path: root/src/screens
diff options
context:
space:
mode:
Diffstat (limited to 'src/screens')
-rw-r--r--src/screens/search/RequestContactsAccess.tsx27
1 files changed, 23 insertions, 4 deletions
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 (
<LinearGradient
colors={BACKGROUND_GRADIENT_MAP[BackgroundGradientType.Light]}
@@ -67,16 +88,14 @@ const RequestContactsAccess: React.FC = () => {
</Text>
</View>
<TouchableOpacity
- onPress={() => {
- console.log('Show IOS opoup');
- }}
+ onPress={handleAllowAccess}
style={styles.allowButton}>
<Text style={styles.allowButtonLabel}>Allow Contacts</Text>
</TouchableOpacity>
<TouchableOpacity
accessibilityLabel="Don't allow button"
style={styles.dontAllowButton}
- onPress={() => navigation.pop()}>
+ onPress={handleDontAllowAccess}>
<Text style={styles.dontAllowButtonText}>Don’t Allow</Text>
</TouchableOpacity>
</View>