This commit is contained in:
xmflsct 2023-03-10 13:45:01 +01:00
parent 6e8cefd7c2
commit af991fdc56
1 changed files with 7 additions and 4 deletions

View File

@ -37,6 +37,9 @@ const TabMePush: React.FC = () => {
const appsQuery = useAppsQuery()
const [pushEnabled, setPushEnabled] = useState<boolean>()
const [pushCanAskAgain, setPushCanAskAgain] = useState<boolean>()
const checkPush = async () => {
const permissions = await Notifications.getPermissionsAsync()
setPushEnabled(permissions.granted)
@ -47,6 +50,9 @@ const TabMePush: React.FC = () => {
useEffect(() => {
checkPush()
}, [])
useEffect(() => {
checkPush()
}, [pushEnabled])
useEffect(() => {
const subscription = AppState.addEventListener('change', checkPush)
return () => {
@ -54,9 +60,6 @@ const TabMePush: React.FC = () => {
}
}, [])
const [pushEnabled, setPushEnabled] = useState<boolean>()
const [pushCanAskAgain, setPushCanAskAgain] = useState<boolean>()
const alerts = () =>
push?.alerts
? PUSH_DEFAULT().map(alert => (
@ -121,7 +124,7 @@ const TabMePush: React.FC = () => {
<ScrollView>
{!!appsQuery.data?.vapid_key ? (
<>
{!!expoToken?.length ? (
{!!expoToken?.length || (!expoToken?.length && !pushEnabled) ? (
<>
{pushEnabled === false ? (
<MenuContainer>