Only request notification permission once per session (#11004)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
@@ -225,6 +225,14 @@ export function useNotificationsRegistration() {
|
|||||||
}, [currentAccount, getAndRegisterPushToken, registerPushToken, aa])
|
}, [currentAccount, getAndRegisterPushToken, registerPushToken, aa])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tracks whether we have already shown the OS notification permission prompt
|
||||||
|
* during this app session. On Android `canAskAgain` stays true after a single
|
||||||
|
* in-app denial, so without this guard a later call site (e.g. Home after
|
||||||
|
* Login) would surface a second prompt. Resets on app restart.
|
||||||
|
*/
|
||||||
|
let hasRequestedPermissionsThisSession = false
|
||||||
|
|
||||||
export function useRequestNotificationsPermission() {
|
export function useRequestNotificationsPermission() {
|
||||||
const ax = useAnalytics()
|
const ax = useAnalytics()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
@@ -249,6 +257,11 @@ export function useRequestNotificationsPermission() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasRequestedPermissionsThisSession) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
hasRequestedPermissionsThisSession = true
|
||||||
|
|
||||||
const res = await Notifications.requestPermissionsAsync({
|
const res = await Notifications.requestPermissionsAsync({
|
||||||
ios: {
|
ios: {
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user