Skip to content

Commit

Permalink
Fix ios (#25)
Browse files Browse the repository at this point in the history
* fix

* fix chotex.

* fix

* fixx2.

* logout on failure.
  • Loading branch information
olifer97 authored Jul 27, 2020
1 parent c747511 commit ad14003
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@expo/vector-icons": "^10.0.0",
"@react-native-community/eslint-config": "^1.1.0",
"@react-native-community/masked-view": "0.1.10",
"@react-navigation/core": "5.11.1",
"@react-navigation/bottom-tabs": "^5.2.7",
"@react-navigation/native": "^5.1.5",
"@react-navigation/stack": "^5.2.10",
Expand Down
10 changes: 8 additions & 2 deletions src/app/screens/HomeScreen/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useCallback, useEffect } from 'react';
import { Platform } from 'react-native';
import { useDispatch, useSelector } from 'react-redux';
import { SafeAreaView } from 'react-native';
import * as Notifications from 'expo-notifications';
Expand All @@ -24,8 +25,13 @@ function HomeScreen({ navigation }) {
console.warn(notification);
});
Notifications.addNotificationResponseReceivedListener((response) => {
const { type, ...data } = response.notification.request.content.data;
const { redirect, payload } = notificationHanlder(data)[type];
let data;
if (Platform.OS === 'ios') {
data = response.notification.request.content.data.body;
} else {
data = response.notification.request.content.data;
}
const { redirect, payload } = notificationHanlder(data)[data.type];
navigation.navigate(redirect, payload);
});
return () => Notifications.removeAllNotificationListeners();
Expand Down
6 changes: 6 additions & 0 deletions src/app/screens/LoginScreen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ function LoginScreen({ navigation }) {
}
}, [token, cleanLogin, navigation]);

useEffect(() => {
if (error) {
setGoogleLoading(false);
}
}, [error]);

useEffect(() => {
initAsync();
}, [initAsync]);
Expand Down
5 changes: 4 additions & 1 deletion src/redux/auth/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ export const actionCreator = {
if (response?.ok) {
setSession(response.data);
dispatch(actionCreator.loginSuccess(response.data));
} else dispatch(actionCreator.loginFailure(response?.data.reason));
} else {
await GoogleSignIn.signOutAsync();
dispatch(actionCreator.loginFailure(response?.data.reason));
}
}
};

Expand Down

0 comments on commit ad14003

Please sign in to comment.