Now fix push not available

Because expo-application is not installed
This commit is contained in:
Zhiyuan Zheng 2022-05-15 00:40:49 +02:00
parent de495d26d7
commit 265db6abce
4 changed files with 13 additions and 17 deletions

View File

@ -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<Notifications.ExpoPushToken>()
const [pushAvailable, setPushAvailable] = useState<boolean>()
const [pushEnabled, setPushEnabled] = useState<boolean>()
const [pushCanAskAgain, setPushCanAskAgain] = useState<boolean>()
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 = () => {
/>
</MenuContainer>
<MenuContainer>{alerts}</MenuContainer>
{!isRelease ? (
<MenuContainer>
<CustomText fontSize='M' style={{ color: colors.primaryDefault }}>
{pushAvailable.data}
</CustomText>
</MenuContainer>
) : null}
</>
) : (
<View

View File

@ -25,7 +25,8 @@ const pushUseConnect = ({ t, instances }: Params) => {
? 'DEVELOPMENT_TOKEN_1'
: (
await Notifications.getExpoPushTokenAsync({
experienceId: '@xmflsct/tooot'
experienceId: '@xmflsct/tooot',
applicationId: 'com.xmflsct.tooot.app'
})
).data

View File

@ -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

View File

@ -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