fix: request notification permission on enable#1004
Conversation
39ba59d to
742e4a7
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e1d1ae8cce
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Greptile SummaryThis PR fixes the Android notification permission prompt appearing automatically on every app open, aligning with the iOS behavior where the OS dialog is only shown when the user explicitly taps "Enable" on the background payments intro sheet.
Confidence Score: 5/5The change is a clean, focused UX fix with no business logic changes — it only rewires where the OS permission dialog is triggered. Both changed paths behave correctly. The launcher is registered at the right Compose scope, the Android 13+ guard is in place, and the pre-13 fallback matches documented QA test cases. The RequestNotificationPermissions lifecycle observer continues to keep granted state in sync when users change settings externally. No files require special attention.
|
| Filename | Overview |
|---|---|
| app/src/main/java/to/bitkit/ui/ContentView.kt | Registers a new notification permission launcher at ContentView scope, moves OS dialog trigger from home-screen auto-prompt to the explicit Enable button, and sets showPermissionDialog=false on RequestNotificationPermissions. Logic is correct and handles pre-API 33 fallback. |
| changelog.d/next/1004.fixed.md | Changelog entry accurately describes the UX change. |
Sequence Diagram
sequenceDiagram
participant User
participant HomeScreen
participant RequestNotificationPermissions
participant BackgroundPaymentsIntroSheet
participant ContentView
participant OS as Android OS
Note over HomeScreen,RequestNotificationPermissions: Before PR - dialog auto-prompted
HomeScreen->>RequestNotificationPermissions: "showPermissionDialog=true (old)"
RequestNotificationPermissions->>OS: launch POST_NOTIFICATIONS dialog
OS-->>User: Permission dialog shown on every open
Note over HomeScreen,OS: After PR - dialog only on explicit Enable
HomeScreen->>RequestNotificationPermissions: "showPermissionDialog=false"
RequestNotificationPermissions->>RequestNotificationPermissions: Sync granted/denied state only (ON_RESUME)
User->>BackgroundPaymentsIntroSheet: Tap Enable
BackgroundPaymentsIntroSheet->>ContentView: onEnable()
ContentView->>ContentView: dismissTimedSheet() + setBgPaymentsIntroSeen(true)
alt Android 13+
ContentView->>OS: notificationPermissionLauncher.launch(POST_NOTIFICATIONS)
OS-->>User: Permission dialog shown once
OS-->>ContentView: granted: Boolean
ContentView->>ContentView: settingsViewModel.setNotificationPreference(granted)
else Android less than 13
ContentView->>HomeScreen: navController.navigateTo(BackgroundPaymentsSettings)
end
Reviews (1): Last reviewed commit: "fix: navigate to payment settings on and..." | Re-trigger Greptile
|
I prioritized matching the iOS flow, because the current behavior is really annoying for a user that don't want to enable notifications. Some UX improvements could be addressed in follow-up PRs:
|
Should've been this way from native v1 🤝 , it's part of how Google suggests to implement these in their Android guidelines |
There was a problem hiding this comment.
tAck
I would expect this to work in same way also in:
- Transfer to Spending > Toggle BG Payments ON
- CJIT Flow > same Toggle ON
Any specific reasons why it doesn't? Even If iOS doesn't do the same, I kinda still think Android should.
Rec - Transfer to Spending
transfer.mp4
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | ||
| notificationPermissionLauncher.launch( | ||
| Manifest.permission.POST_NOTIFICATIONS | ||
| ) | ||
| } else { | ||
| // Pre-13 has no runtime permission dialog; open the | ||
| // in-app background payments settings instead. | ||
| navController.navigateTo(Routes.BackgroundPaymentsSettings) | ||
| } |
There was a problem hiding this comment.
nit: this belongs to a reusable top level fn, not inline in a handler, especially because other entrypoints should be handled the same way…
Closes #566
This PR stops the Android notification permission system dialog from appearing automatically on the home screen, requesting it only when the user taps "Enable" on the background payments prompt.
Description
The home screen previously asked
RequestNotificationPermissionsto launch thePOST_NOTIFICATIONSsystem dialog on every entry while notifications were ungranted, so a user who dismissed it kept getting re-prompted on each app open. Issue #566 asked to gate how often this appears; this aligns Android with the iOS flow, where the dialog is only triggered from the background payments intro sheet's "Enable" button (NotificationsSheet→requestPermission()).RequestNotificationPermissionsnow runs withshowPermissionDialog = false, so it only keeps the granted/denied state in sync (including when the user changes it in system settings); it no longer launches the dialog.TIRAMISU); on older versions, where there is no runtime notification permission, "Enable" simply dismisses.The background payments prompt itself is unchanged: it still appears only when notifications are not yet granted and the wallet has a Lightning spending balance.
Preview
before.webm
allow-flow.webm
deny-flow.webm
suggestion-intro.webm
android-11-enable-flow.webm
QA Notes
Manual Tests
regression:Background payments prompt → tap Later: sheet dismisses, no OS dialog.regression:Android 12 or below → tap Enable: navigate to payment settings (no runtime permission).OBS: On Android 12 or bellow, the notifications are enabled by default
Automated Checks
ContentViewonly; no business logic added.just compileandjust lintpass.