From 9df4add4353647cc193347b4e881e9344e3ae539 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 30 Jun 2026 23:22:37 +0300 Subject: [PATCH] Only request notification permission once per session (#11004) Co-authored-by: Claude Co-authored-by: Eric Bailey --- src/lib/notifications/notifications.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lib/notifications/notifications.ts b/src/lib/notifications/notifications.ts index e8de8e9de3..008b2ef73f 100644 --- a/src/lib/notifications/notifications.ts +++ b/src/lib/notifications/notifications.ts @@ -225,6 +225,14 @@ export function useNotificationsRegistration() { }, [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() { const ax = useAnalytics() const {currentAccount} = useSession() @@ -249,6 +257,11 @@ export function useRequestNotificationsPermission() { return } + if (hasRequestedPermissionsThisSession) { + return + } + hasRequestedPermissionsThisSession = true + const res = await Notifications.requestPermissionsAsync({ ios: { /*