[🐴] Don't always show notification for everything (#4083)

* don't always show a notification

* nit
zio/stable
Hailey 2024-05-17 09:23:46 -07:00 committed by GitHub
parent dd4c8d8e4f
commit 5e312d5f3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -41,7 +41,7 @@ type NotificationPayload =
}
const DEFAULT_HANDLER_OPTIONS = {
shouldShowAlert: true,
shouldShowAlert: false,
shouldPlaySound: false,
shouldSetBadge: true,
}

View File

@ -71,12 +71,14 @@ export function useNotificationsRegistration() {
export function useRequestNotificationsPermission() {
const gate = useGate()
const {currentAccount} = useSession()
return React.useCallback(
async (context: 'StartOnboarding' | 'AfterOnboarding' | 'Login') => {
const permissions = await Notifications.getPermissionsAsync()
if (
!currentAccount ||
!isNative ||
permissions?.status === 'granted' ||
(permissions?.status === 'denied' && !permissions?.canAskAgain)
@ -107,7 +109,7 @@ export function useRequestNotificationsPermission() {
getPushToken(true)
}
},
[gate],
[gate, currentAccount],
)
}