[🐴] Don't always show notification for everything (#4083)
* don't always show a notification * nit
This commit is contained in:
parent
dd4c8d8e4f
commit
5e312d5f3a
2 changed files with 4 additions and 2 deletions
|
@ -41,7 +41,7 @@ type NotificationPayload =
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_HANDLER_OPTIONS = {
|
const DEFAULT_HANDLER_OPTIONS = {
|
||||||
shouldShowAlert: true,
|
shouldShowAlert: false,
|
||||||
shouldPlaySound: false,
|
shouldPlaySound: false,
|
||||||
shouldSetBadge: true,
|
shouldSetBadge: true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,12 +71,14 @@ export function useNotificationsRegistration() {
|
||||||
|
|
||||||
export function useRequestNotificationsPermission() {
|
export function useRequestNotificationsPermission() {
|
||||||
const gate = useGate()
|
const gate = useGate()
|
||||||
|
const {currentAccount} = useSession()
|
||||||
|
|
||||||
return React.useCallback(
|
return React.useCallback(
|
||||||
async (context: 'StartOnboarding' | 'AfterOnboarding' | 'Login') => {
|
async (context: 'StartOnboarding' | 'AfterOnboarding' | 'Login') => {
|
||||||
const permissions = await Notifications.getPermissionsAsync()
|
const permissions = await Notifications.getPermissionsAsync()
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
!currentAccount ||
|
||||||
!isNative ||
|
!isNative ||
|
||||||
permissions?.status === 'granted' ||
|
permissions?.status === 'granted' ||
|
||||||
(permissions?.status === 'denied' && !permissions?.canAskAgain)
|
(permissions?.status === 'denied' && !permissions?.canAskAgain)
|
||||||
|
@ -107,7 +109,7 @@ export function useRequestNotificationsPermission() {
|
||||||
getPushToken(true)
|
getPushToken(true)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[gate],
|
[gate, currentAccount],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue