From 265db6abce20efc6ecfafe31fb4f6e31bd3010cd Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Sun, 15 May 2022 00:40:49 +0200 Subject: [PATCH] Now fix push not available Because expo-application is not installed --- src/screens/Tabs/Me/Push.tsx | 21 +++++++------------ src/utils/push/useConnect.ts | 3 ++- src/utils/slices/instances/updatePush.ts | 3 ++- .../slices/instances/updatePushDecode.ts | 3 ++- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/screens/Tabs/Me/Push.tsx b/src/screens/Tabs/Me/Push.tsx index 568ccc17..8450ca9d 100644 --- a/src/screens/Tabs/Me/Push.tsx +++ b/src/screens/Tabs/Me/Push.tsx @@ -4,7 +4,7 @@ import Icon from '@components/Icon' import { MenuContainer, MenuRow } from '@components/Menu' import CustomText from '@components/Text' import { useAppDispatch } from '@root/store' -import { isDevelopment, isRelease } from '@utils/checkEnvironment' +import { isDevelopment } from '@utils/checkEnvironment' import { updateInstancePush } from '@utils/slices/instances/updatePush' import { updateInstancePushAlert } from '@utils/slices/instances/updatePushAlert' import { updateInstancePushDecode } from '@utils/slices/instances/updatePushDecode' @@ -36,8 +36,7 @@ const TabMePush: React.FC = () => { const dispatch = useAppDispatch() const instancePush = useSelector(getInstancePush) - const [pushAvailable, setPushAvailable] = - useState() + const [pushAvailable, setPushAvailable] = useState() const [pushEnabled, setPushEnabled] = useState() const [pushCanAskAgain, setPushCanAskAgain] = useState() const checkPush = async () => { @@ -48,13 +47,14 @@ const TabMePush: React.FC = () => { } useEffect(() => { if (isDevelopment) { - setPushAvailable({ data: '', type: 'expo' }) + setPushAvailable(true) } else { Notifications.getExpoPushTokenAsync({ - experienceId: '@xmflsct/tooot' + experienceId: '@xmflsct/tooot', + applicationId: 'com.xmflsct.tooot.app' }) - .then(data => setPushAvailable(data)) - .catch(() => setPushAvailable(undefined)) + .then(data => setPushAvailable(!!data)) + .catch(() => setPushAvailable(false)) } checkPush() @@ -190,13 +190,6 @@ const TabMePush: React.FC = () => { /> {alerts} - {!isRelease ? ( - - - {pushAvailable.data} - - - ) : null} ) : ( { ? 'DEVELOPMENT_TOKEN_1' : ( await Notifications.getExpoPushTokenAsync({ - experienceId: '@xmflsct/tooot' + experienceId: '@xmflsct/tooot', + applicationId: 'com.xmflsct.tooot.app' }) ).data diff --git a/src/utils/slices/instances/updatePush.ts b/src/utils/slices/instances/updatePush.ts index 75b4e54e..9930acd8 100644 --- a/src/utils/slices/instances/updatePush.ts +++ b/src/utils/slices/instances/updatePush.ts @@ -17,7 +17,8 @@ export const updateInstancePush = createAsyncThunk( ? 'DEVELOPMENT_TOKEN_1' : ( await Notifications.getExpoPushTokenAsync({ - experienceId: '@xmflsct/tooot' + experienceId: '@xmflsct/tooot', + applicationId: 'com.xmflsct.tooot.app' }) ).data diff --git a/src/utils/slices/instances/updatePushDecode.ts b/src/utils/slices/instances/updatePushDecode.ts index d8f18804..c8c6a4a0 100644 --- a/src/utils/slices/instances/updatePushDecode.ts +++ b/src/utils/slices/instances/updatePushDecode.ts @@ -24,7 +24,8 @@ export const updateInstancePushDecode = createAsyncThunk( ? 'DEVELOPMENT_TOKEN_1' : ( await Notifications.getExpoPushTokenAsync({ - experienceId: '@xmflsct/tooot' + experienceId: '@xmflsct/tooot', + applicationId: 'com.xmflsct.tooot.app' }) ).data