-
Notifications
You must be signed in to change notification settings - Fork 3
fix: request notification permission on enable #1004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jvsena42
wants to merge
7
commits into
master
Choose a base branch
from
fix/limit-system-notification-permission
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
742e4a7
fix: request notification permission on enable
jvsena42 e1d1ae8
fix: navigate to payment settings on android pre 13
jvsena42 f8f20a3
fix: trigger OS dialog from intro flow
jvsena42 79b2230
fix: apply OS permission dialog on bg notification switch
jvsena42 5febf95
Merge branch 'master' into fix/limit-system-notification-permission
jvsena42 c36f744
fix: navigate to settings on switch off
jvsena42 cfbe337
test: update journeys
jvsena42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| The system notification permission dialog is now only requested when you tap Enable on the background payments prompt, instead of appearing automatically on every app open. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Notification-permission journeys | ||
|
|
||
| These journeys exercise the notification-permission request triggered by the | ||
| "Set up in background" toggle that backs Bitkit's background-payments setup. | ||
|
|
||
| The behaviour was changed on `fix/limit-system-notification-permission`: tapping the | ||
| toggle now goes through the shared `rememberRequestNotificationPermission` helper | ||
| (`ui/utils/RequestNotificationPermissions.kt`) instead of jumping straight to the | ||
| system notification settings. | ||
|
|
||
| ## What the fix does | ||
| - **Toggle OFF (permission already granted)**: re-requesting a granted permission is a | ||
| no-op, so tapping opens the **system notification settings** (`openNotificationSettings`) | ||
| where the user can actually turn notifications off — the behaviour these toggles had | ||
| before the refactor. | ||
| - **Toggle ON, Android 13+ (API 33, TIRAMISU)**: tapping launches the OS | ||
| `POST_NOTIFICATIONS` runtime permission dialog. Granting it flips the toggle to | ||
| checked; the result is persisted via `SettingsViewModel.setNotificationPreference`. | ||
| - **Toggle ON, pre-13 (API < 33)**: there is no runtime dialog, so it falls back to the | ||
| system notification settings. | ||
|
|
||
| The same helper backs four entry points; these journeys cover the three the user can | ||
| reach directly: | ||
| - **Transfer → Spending confirm** (`SpendingConfirmScreen`) | ||
| - **Receive → CJIT confirm** (`ReceiveConfirmScreen`) | ||
| - **Receive → CJIT liquidity** (`ReceiveLiquidityScreen`, via "Learn more") | ||
|
|
||
| ## Mandatory setup | ||
| 1. **Use an API 33+ device** to verify the runtime-dialog path. On API < 33 the dialog | ||
| never appears — only the system-settings fallback is exercised. | ||
| 2. **Start from a fresh notification-permission state.** The OS only shows the | ||
| `POST_NOTIFICATIONS` dialog while the permission is in the "ask" state. Once granted | ||
| or denied it will not show again, and the journey will silently pass for the wrong | ||
| reason. Reset before each run: | ||
| `adb shell pm revoke to.bitkit.dev android.permission.POST_NOTIFICATIONS` | ||
| (or reinstall / clear app data). | ||
| 3. **Node must be connected to the LSP (Blocktank).** Both the Transfer→Spending and | ||
| Receive→CJIT confirm screens need a real order quoted by Blocktank before the toggle | ||
| screen renders. With the hosted staging backend this is `api.stag0.blocktank.to`. | ||
| 4. **Transfer→Spending also needs a positive on-chain Savings balance** so a real max can | ||
| be quoted. Fund + mine via the `blocktank-api:lsp` skill, then wait for the balance to | ||
| sync. | ||
|
|
||
| ## Gotchas | ||
| - **The permission dialog is one-shot** — see setup #2. Always revoke/reset first. | ||
| - **Blocktank must be reachable.** If `api.stag0.blocktank.to:443` is down, CJIT/order | ||
| creation hangs on a spinner at "Continue" and the confirm screen never appears, so the | ||
| toggle is unreachable. Verify the host first: | ||
| `curl -s -m 8 -o /dev/null -w '%{http_code}\n' https://api.stag0.blocktank.to/blocktank/api/v2/info` | ||
| (`000` = down). This is infra, not the toggle. | ||
| - The system permission dialog is **OS UI**, not Compose — locate its buttons with | ||
| `android screen --annotate` (text "Allow" / "Don't allow"), not `android layout` tags. | ||
| - On grant, the toggle reflects `notificationsGranted`; it only flips to checked once the | ||
| `ON_RESUME` re-check or the launcher callback fires. | ||
|
|
||
| ## Test tags | ||
| - Transfer→Spending toggle switch: `SpendingConfirmNotificationSwitch` | ||
| - Receive→CJIT confirm toggle switch: `ReceiveConfirmNotificationSwitch` | ||
| - Receive→CJIT liquidity toggle switch: `ReceiveLiquidityNotificationSwitch` | ||
| - Spending amount screen: `SpendingAmount`, continue `SpendingAmountContinue`, | ||
| available/max `SpendingAmountAvailable` / `SpendingAmountMax`. | ||
| - The toggle label on all screens is "Set up in background". |
23 changes: 23 additions & 0 deletions
23
journeys/notification-permission/receive-cjit-confirm-notification-toggle.xml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <journey name="receive cjit confirm toggle requests notification permission"> | ||
| <description> | ||
| Verifies that the "Set up in background" toggle on the Receive → CJIT confirm screen | ||
| (ReceiveConfirmScreen) launches the Android POST_NOTIFICATIONS runtime permission | ||
| dialog on API 33+, and that granting it checks the toggle. | ||
|
|
||
| Precondition: API 33+ onboarded dev wallet with the node connected to the LSP so a | ||
| CJIT order can be quoted, and POST_NOTIFICATIONS in the "ask" state (revoke or | ||
| reinstall first — the dialog is one-shot). Start on the wallet home screen. | ||
| </description> | ||
| <actions> | ||
| <action>Tap the "Receive" button on the home screen</action> | ||
| <action>Tap the "Spending" tab in the Receive sheet</action> | ||
| <action>Tap "Receive Lightning funds"</action> | ||
| <action>On the amount screen, enter an amount above the CJIT minimum (e.g. 100 000 sats) using the number pad</action> | ||
| <action>Tap "Continue" and wait for the CJIT order to be created and the confirm screen ("To set up your spending balance...") to appear</action> | ||
| <action>Verify the "Set up in background" toggle (testTag "ReceiveConfirmNotificationSwitch") is visible and unchecked</action> | ||
| <action>Tap the "Set up in background" toggle</action> | ||
| <action>Verify the Android system notification permission dialog appears (text like "Allow Bitkit to send you notifications?")</action> | ||
| <action>Tap "Allow"</action> | ||
| <action>Verify the "Set up in background" toggle is now checked</action> | ||
| </actions> | ||
| </journey> |
25 changes: 25 additions & 0 deletions
25
journeys/notification-permission/receive-cjit-liquidity-notification-toggle.xml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <journey name="receive cjit liquidity toggle requests notification permission"> | ||
| <description> | ||
| Verifies that the "Set up in background" toggle on the Receive → CJIT liquidity screen | ||
| (ReceiveLiquidityScreen, reached via "Learn more" from the confirm screen) launches the | ||
| Android POST_NOTIFICATIONS runtime permission dialog on API 33+, and that granting it | ||
| checks the toggle. | ||
|
|
||
| Precondition: API 33+ onboarded dev wallet with the node connected to the LSP so a CJIT | ||
| order can be quoted, and POST_NOTIFICATIONS in the "ask" state (revoke or reinstall | ||
| first — the dialog is one-shot). Start on the wallet home screen. | ||
| </description> | ||
| <actions> | ||
| <action>Tap the "Receive" button on the home screen</action> | ||
| <action>Tap the "Spending" tab in the Receive sheet</action> | ||
| <action>Tap "Receive Lightning funds"</action> | ||
| <action>On the amount screen, enter an amount above the CJIT minimum (e.g. 100 000 sats) using the number pad</action> | ||
| <action>Tap "Continue" and wait for the confirm screen to appear</action> | ||
| <action>Tap "Learn more" to open the liquidity screen</action> | ||
| <action>Verify the liquidity screen with the lightning channel and the "Set up in background" toggle (testTag "ReceiveLiquidityNotificationSwitch") is visible and unchecked</action> | ||
| <action>Tap the "Set up in background" toggle</action> | ||
| <action>Verify the Android system notification permission dialog appears (text like "Allow Bitkit to send you notifications?")</action> | ||
| <action>Tap "Allow"</action> | ||
| <action>Verify the "Set up in background" toggle is now checked</action> | ||
| </actions> | ||
| </journey> |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.