fix(mobile): recover push activation when the notification permission is blocked - #181
Open
JordiMa wants to merge 1 commit into
Open
fix(mobile): recover push activation when the notification permission is blocked#181JordiMa wants to merge 1 commit into
JordiMa wants to merge 1 commit into
Conversation
… is blocked Distinguish a permanently blocked notification permission from a simple denial: when Android (or iOS) can no longer show the permission prompt, the push toggle now surfaces an alert with an Open settings action that deep-links to the app's system settings instead of failing silently. Also stop the settings screen's passive re-registration effect from requesting the permission: it raced the toggle's own request and could burn both of Android 13's allowed prompts in a single interaction, permanently blocking activation. The effect now only syncs an already-granted token.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Users reported that enabling push notifications in the Android app sometimes does nothing — not reproducible on every phone.
Two root causes, which reinforce each other:
Permanently blocked permission = silent dead end. On Android 13+, the system only allows the notification permission prompt to be shown twice. Once that budget is spent (or when notifications are disabled for the app in system settings),
requestPermissionsAsync()returns denied instantly without showing any dialog. The toggle just snapped back with a generic "permission denied" message and no way to recover from inside the app. Whether a phone is in this state depends on its denial history, which explains the inconsistent reproduction.A concurrent duplicate permission request burned both prompts in one interaction. The settings screen has a passive re-registration effect keyed on
push_enabled. The toggle's optimistic cache update fired that effect mid-activation, so a secondrequestPermissionsAsync()was queued behind the toggle's own request (expo-modules-core queues concurrent requests). If the user denied the first dialog, the second (and final) one appeared immediately behind it — a single decline could permanently block the permission, feeding phones into state 1.Fix
PushNotificationService.requestExpoPushToken()now returns aPushTokenRequestStatus(Granted/Denied/Blocked/Unsupported) instead of a bare token, usingcanAskAgainto detect the permanently blocked state.registerDeviceForPushshows a native alert with an Open settings action (Linking.openSettings()) that deep-links to the app's system settings, plus an inline explanation message. The onboarding enable-push flow benefits from the same handling.use-settings.tsnow uses the non-promptinggetGrantedExpoPushToken(), so only the toggle itself can trigger the permission prompt — the duplicate-request race is gone, and opening the settings screen can no longer spontaneously show a permission dialog.en/frstrings for the blocked state.Tests
requestExpoPushToken()status resolution (already granted, granted from prompt, denied-but-askable, permanently blocked, web).nx typecheck mobile, lint, andnx export mobileall pass.Notes
push_enabled: trueserver-side, so turning push OFF does not survive an app restart. Left out of scope here; can open a follow-up if wanted.