diff options
author | Ivan Chen <ivan@tagg.id> | 2021-02-05 15:27:00 -0500 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-02-05 15:27:00 -0500 |
commit | 2c69c7a49fcbc92fa1024a0e83c3bad669672e91 (patch) | |
tree | 8f770863bc0f1f1892ea946677ecf481a2abeaa6 /src/routes/Routes.tsx | |
parent | 54027f2b5b763550fd11d1df6c5b979a7528170d (diff) |
moved permission to routes
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 />; }; |