aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Chen <ivan@thetaggid.com>2021-02-05 16:47:17 -0500
committerGitHub <noreply@github.com>2021-02-05 16:47:17 -0500
commited866c9304a4996c4cdfb19224b7ea26c2ee7e32 (patch)
treed05e9e2a48dbc6d9986add1e36ba32ded9699b32 /src
parentc3cd8f95c6534fb5eb78af299ef424c50aefd85a (diff)
parent94d38350ba0bcfd0bc3095d8628de67fbe6ee6dc (diff)
Merge pull request #221 from IvanIFChen/tma607-notification-permission-after-onboarding
[TMA-607] Moved Permission to After Login
Diffstat (limited to 'src')
-rw-r--r--src/App.tsx12
-rw-r--r--src/routes/Routes.tsx8
-rw-r--r--src/screens/onboarding/CategorySelection.tsx3
3 files changed, 12 insertions, 11 deletions
diff --git a/src/App.tsx b/src/App.tsx
index 18fadf64..ea3617dc 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,17 +1,11 @@
-import React, {useEffect} from 'react';
import {NavigationContainer} from '@react-navigation/native';
-import Routes from './routes';
+import React from 'react';
import {Provider} from 'react-redux';
-import store from './store/configureStore';
-import {fcmService} from './services/FCMService';
import {navigationRef} from './RootNavigation';
+import Routes from './routes';
+import store from './store/configureStore';
const App = () => {
- useEffect(() => {
- fcmService.setUpPushNotifications();
- // TODO: If permissions are not there, deactivateFcmService
- });
-
return (
/**
* This is the provider from the redux store, it acts as the root provider for our application
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/screens/onboarding/CategorySelection.tsx b/src/screens/onboarding/CategorySelection.tsx
index a3acbbb7..94dd44b2 100644
--- a/src/screens/onboarding/CategorySelection.tsx
+++ b/src/screens/onboarding/CategorySelection.tsx
@@ -17,7 +17,7 @@ import {Background, MomentCategory} from '../../components';
import {MOMENT_CATEGORIES} from '../../constants';
import {ERROR_SOMETHING_WENT_WRONG} from '../../constants/strings';
import {OnboardingStackParams} from '../../routes';
-import {fcmService, postMomentCategories} from '../../services';
+import {postMomentCategories} from '../../services';
import {
updateIsOnboardedUser,
updateMomentCategories,
@@ -169,7 +169,6 @@ const CategorySelection: React.FC<CategorySelectionProps> = ({
const token = await getTokenOrLogout(dispatch);
await postMomentCategories(selectedCategories, token);
userLogin(dispatch, {userId: userId, username: username});
- fcmService.sendFcmTokenToServer();
} else {
dispatch(
updateMomentCategories(