diff options
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/Routes.tsx | 8 | ||||
| -rw-r--r-- | src/routes/main/MainStackNavigator.tsx | 3 | ||||
| -rw-r--r-- | src/routes/main/MainStackScreen.tsx | 33 |
3 files changed, 36 insertions, 8 deletions
diff --git a/src/routes/Routes.tsx b/src/routes/Routes.tsx index a14f1576..a5383a47 100644 --- a/src/routes/Routes.tsx +++ b/src/routes/Routes.tsx @@ -7,6 +7,7 @@ import {userLogin} from '../utils'; import SplashScreen from 'react-native-splash-screen'; import messaging from '@react-native-firebase/messaging'; import {updateNewNotificationReceived} from '../store/actions'; +import {fcmService} from '../services'; const Routes: React.FC = () => { const { @@ -39,6 +40,13 @@ const Routes: React.FC = () => { } }, [dispatch, userId]); + useEffect(() => { + if (userId) { + fcmService.setUpPushNotifications(); + fcmService.sendFcmTokenToServer(); + } + }); + return userId ? <NavigationBar /> : <Onboarding />; }; diff --git a/src/routes/main/MainStackNavigator.tsx b/src/routes/main/MainStackNavigator.tsx index 663aeaea..74993af9 100644 --- a/src/routes/main/MainStackNavigator.tsx +++ b/src/routes/main/MainStackNavigator.tsx @@ -14,6 +14,9 @@ export type MainStackParams = { Search: { screenType: ScreenType; }; + RequestContactsAccess: { + screenType: ScreenType; + }; Profile: { userXId: string | undefined; screenType: ScreenType; diff --git a/src/routes/main/MainStackScreen.tsx b/src/routes/main/MainStackScreen.tsx index 47b49f07..c0cef3ea 100644 --- a/src/routes/main/MainStackScreen.tsx +++ b/src/routes/main/MainStackScreen.tsx @@ -1,6 +1,7 @@ +import AsyncStorage from '@react-native-community/async-storage'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationOptions} from '@react-navigation/stack'; -import React from 'react'; +import React, {useState} from 'react'; import { CaptionScreen, CategorySelection, @@ -12,6 +13,7 @@ import { MomentUploadPromptScreen, NotificationsScreen, ProfileScreen, + RequestContactsAccess, SearchScreen, SocialMediaTaggs, } from '../../screens'; @@ -42,6 +44,14 @@ const MainStackScreen: React.FC<MainStackProps> = ({route}) => { const isSearchTab = screenType === ScreenType.Search; const isNotificationsTab = screenType === ScreenType.Notifications; + AsyncStorage.getItem('respondedToAccessContacts').then((value) => + setRespondedToAccessContacts(value ? value : 'false'), + ); + + const [respondedToAccessContacts, setRespondedToAccessContacts] = useState( + 'false', + ); + const initialRouteName = (() => { switch (screenType) { case ScreenType.Profile: @@ -90,13 +100,20 @@ const MainStackScreen: React.FC<MainStackProps> = ({route}) => { screenType, }} /> - {isSearchTab && ( - <MainStack.Screen - name="Search" - component={SearchScreen} - initialParams={{screenType}} - /> - )} + {isSearchTab && + (respondedToAccessContacts && respondedToAccessContacts === 'true' ? ( + <MainStack.Screen + name="Search" + component={SearchScreen} + initialParams={{screenType}} + /> + ) : ( + <MainStack.Screen + name="Search" + component={RequestContactsAccess} + initialParams={{screenType}} + /> + ))} {isNotificationsTab && ( <MainStack.Screen name="Notifications" |
