From a74bc24d29366917c33aea240a9a71e595d8c55f Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Wed, 21 Apr 2021 15:23:09 -0400 Subject: fixed --- src/routes/main/MainStackScreen.tsx | 47 ++++++++++--------------------------- 1 file changed, 12 insertions(+), 35 deletions(-) (limited to 'src/routes') diff --git a/src/routes/main/MainStackScreen.tsx b/src/routes/main/MainStackScreen.tsx index 37867151..f5100e58 100644 --- a/src/routes/main/MainStackScreen.tsx +++ b/src/routes/main/MainStackScreen.tsx @@ -1,7 +1,6 @@ -import AsyncStorage from '@react-native-community/async-storage'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationOptions} from '@react-navigation/stack'; -import React, {useEffect, useState} from 'react'; +import React from 'react'; import {StyleSheet, Text} from 'react-native'; import {normalize} from 'react-native-elements'; import BackIcon from '../../assets/icons/back-arrow.svg'; @@ -56,28 +55,9 @@ interface MainStackProps { const MainStackScreen: React.FC = ({route}) => { const {screenType} = route.params; - // const isProfileTab = screenType === ScreenType.Profile; const isSearchTab = screenType === ScreenType.Search; const isNotificationsTab = screenType === ScreenType.Notifications; const isSuggestedPeopleTab = screenType === ScreenType.SuggestedPeople; - const [respondedToAccessContacts, setRespondedToAccessContacts] = useState( - 'true', - ); - - useEffect(() => { - loadResponseToAccessContacts(); - }, []); - - const loadResponseToAccessContacts = () => { - AsyncStorage.getItem('respondedToAccessContacts') - .then((value) => { - setRespondedToAccessContacts(value ? value : 'false'); - }) - .catch((error) => { - console.log('Something went wrong', error); - setRespondedToAccessContacts('true'); - }); - }; const initialRouteName = (() => { switch (screenType) { @@ -131,20 +111,13 @@ const MainStackScreen: React.FC = ({route}) => { ...headerBarOptions('white', ''), }} /> - {isSuggestedPeopleTab && - (respondedToAccessContacts && respondedToAccessContacts === 'true' ? ( - - ) : ( - - ))} + {isSuggestedPeopleTab && ( + + )} {isNotificationsTab && ( = ({route}) => { name="RequestContactsAccess" component={RequestContactsAccess} initialParams={{screenType}} + options={{ + ...modalStyle, + gestureEnabled: false, + }} /> Date: Fri, 23 Apr 2021 15:34:01 -0400 Subject: fixed device not registering bug --- src/routes/Routes.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/routes') diff --git a/src/routes/Routes.tsx b/src/routes/Routes.tsx index 6fc766ab..c2efbb15 100644 --- a/src/routes/Routes.tsx +++ b/src/routes/Routes.tsx @@ -54,7 +54,7 @@ const Routes: React.FC = () => { fcmService.setUpPushNotifications(); fcmService.sendFcmTokenToServer(); } - }, []); + }); useEffect(() => { if (loggedInUserId) { -- cgit v1.2.3-70-g09d2 From 77082b5cd9c095af6fc289ed24b284c4b738a59d Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 23 Apr 2021 15:34:12 -0400 Subject: sending fcm token to stream --- src/routes/Routes.tsx | 2 +- src/services/FCMService.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/routes') diff --git a/src/routes/Routes.tsx b/src/routes/Routes.tsx index c2efbb15..384021bc 100644 --- a/src/routes/Routes.tsx +++ b/src/routes/Routes.tsx @@ -52,7 +52,7 @@ const Routes: React.FC = () => { useEffect(() => { if (userId) { fcmService.setUpPushNotifications(); - fcmService.sendFcmTokenToServer(); + fcmService.sendFcmTokenToServer(chatClient); } }); diff --git a/src/services/FCMService.ts b/src/services/FCMService.ts index 84f30f09..711483ec 100644 --- a/src/services/FCMService.ts +++ b/src/services/FCMService.ts @@ -2,8 +2,10 @@ import AsyncStorage from '@react-native-community/async-storage'; import messaging from '@react-native-firebase/messaging'; import {Platform} from 'react-native'; import {getDeviceId, getDeviceName} from 'react-native-device-info'; +import {StreamChat} from 'stream-chat'; import {FCM_ENDPOINT} from '../constants'; import * as RootNavigation from '../RootNavigation'; + class FCMService { setUpPushNotifications = () => { // Requesting user to permit notifications @@ -78,10 +80,13 @@ class FCMService { return ''; }; - sendFcmTokenToServer = async () => { + sendFcmTokenToServer = async (chatClient: StreamChat) => { const registration_id: string | null = await AsyncStorage.getItem( '@fcmToken', ); + if (registration_id !== null) { + chatClient.addDevice(registration_id, 'firebase'); + } const device_id = getDeviceId(); const type = Platform.OS; let active: boolean = false; @@ -117,7 +122,6 @@ class FCMService { console.log('Successfully stored device token!'); } else { console.log('Failed to store device token!'); - console.log(response); } } }; -- cgit v1.2.3-70-g09d2