From 2c69c7a49fcbc92fa1024a0e83c3bad669672e91 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 5 Feb 2021 15:27:00 -0500 Subject: moved permission to routes --- src/routes/Routes.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/routes') diff --git a/src/routes/Routes.tsx b/src/routes/Routes.tsx index a14f1576..768a7604 100644 --- a/src/routes/Routes.tsx +++ b/src/routes/Routes.tsx @@ -7,12 +7,14 @@ 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 { user: {userId}, } = useSelector((state: RootState) => state.user); const dispatch = useDispatch(); + const {isOnboardedUser} = useSelector((state: RootState) => state.user); /** * Load the user from AsyncStorage if any @@ -39,6 +41,17 @@ const Routes: React.FC = () => { } }, [dispatch, userId]); + useEffect(() => { + // after onboarding, or user signed in (after reinstall) + if (userId) { + fcmService.setUpPushNotifications(); + } + // user just onboarded + if (isOnboardedUser) { + fcmService.sendFcmTokenToServer(); + } + }); + return userId ? : ; }; -- cgit v1.2.3-70-g09d2