diff options
Diffstat (limited to 'src/routes/Routes.tsx')
-rw-r--r-- | src/routes/Routes.tsx | 13 |
1 files changed, 13 insertions, 0 deletions
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 ? <NavigationBar /> : <Onboarding />; }; |