|
| 1 | +# Notification-permission journeys |
| 2 | + |
| 3 | +These journeys exercise the notification-permission request triggered by the |
| 4 | +"Set up in background" toggle that backs Bitkit's background-payments setup. |
| 5 | + |
| 6 | +The behaviour was changed on `fix/limit-system-notification-permission`: tapping the |
| 7 | +toggle now goes through the shared `rememberRequestNotificationPermission` helper |
| 8 | +(`ui/utils/RequestNotificationPermissions.kt`) instead of jumping straight to the |
| 9 | +system notification settings. |
| 10 | + |
| 11 | +## What the fix does |
| 12 | +- **Toggle OFF (permission already granted)**: re-requesting a granted permission is a |
| 13 | + no-op, so tapping opens the **system notification settings** (`openNotificationSettings`) |
| 14 | + where the user can actually turn notifications off — the behaviour these toggles had |
| 15 | + before the refactor. |
| 16 | +- **Toggle ON, Android 13+ (API 33, TIRAMISU)**: tapping launches the OS |
| 17 | + `POST_NOTIFICATIONS` runtime permission dialog. Granting it flips the toggle to |
| 18 | + checked; the result is persisted via `SettingsViewModel.setNotificationPreference`. |
| 19 | +- **Toggle ON, pre-13 (API < 33)**: there is no runtime dialog, so it falls back to the |
| 20 | + system notification settings. |
| 21 | + |
| 22 | +The same helper backs four entry points; these journeys cover the three the user can |
| 23 | +reach directly: |
| 24 | +- **Transfer → Spending confirm** (`SpendingConfirmScreen`) |
| 25 | +- **Receive → CJIT confirm** (`ReceiveConfirmScreen`) |
| 26 | +- **Receive → CJIT liquidity** (`ReceiveLiquidityScreen`, via "Learn more") |
| 27 | + |
| 28 | +## Mandatory setup |
| 29 | +1. **Use an API 33+ device** to verify the runtime-dialog path. On API < 33 the dialog |
| 30 | + never appears — only the system-settings fallback is exercised. |
| 31 | +2. **Start from a fresh notification-permission state.** The OS only shows the |
| 32 | + `POST_NOTIFICATIONS` dialog while the permission is in the "ask" state. Once granted |
| 33 | + or denied it will not show again, and the journey will silently pass for the wrong |
| 34 | + reason. Reset before each run: |
| 35 | + `adb shell pm revoke to.bitkit.dev android.permission.POST_NOTIFICATIONS` |
| 36 | + (or reinstall / clear app data). |
| 37 | +3. **Node must be connected to the LSP (Blocktank).** Both the Transfer→Spending and |
| 38 | + Receive→CJIT confirm screens need a real order quoted by Blocktank before the toggle |
| 39 | + screen renders. With the hosted staging backend this is `api.stag0.blocktank.to`. |
| 40 | +4. **Transfer→Spending also needs a positive on-chain Savings balance** so a real max can |
| 41 | + be quoted. Fund + mine via the `blocktank-api:lsp` skill, then wait for the balance to |
| 42 | + sync. |
| 43 | + |
| 44 | +## Gotchas |
| 45 | +- **The permission dialog is one-shot** — see setup #2. Always revoke/reset first. |
| 46 | +- **Blocktank must be reachable.** If `api.stag0.blocktank.to:443` is down, CJIT/order |
| 47 | + creation hangs on a spinner at "Continue" and the confirm screen never appears, so the |
| 48 | + toggle is unreachable. Verify the host first: |
| 49 | + `curl -s -m 8 -o /dev/null -w '%{http_code}\n' https://api.stag0.blocktank.to/blocktank/api/v2/info` |
| 50 | + (`000` = down). This is infra, not the toggle. |
| 51 | +- The system permission dialog is **OS UI**, not Compose — locate its buttons with |
| 52 | + `android screen --annotate` (text "Allow" / "Don't allow"), not `android layout` tags. |
| 53 | +- On grant, the toggle reflects `notificationsGranted`; it only flips to checked once the |
| 54 | + `ON_RESUME` re-check or the launcher callback fires. |
| 55 | + |
| 56 | +## Test tags |
| 57 | +- Transfer→Spending toggle switch: `SpendingConfirmNotificationSwitch` |
| 58 | +- Receive→CJIT confirm toggle switch: `ReceiveConfirmNotificationSwitch` |
| 59 | +- Receive→CJIT liquidity toggle switch: `ReceiveLiquidityNotificationSwitch` |
| 60 | +- Spending amount screen: `SpendingAmount`, continue `SpendingAmountContinue`, |
| 61 | + available/max `SpendingAmountAvailable` / `SpendingAmountMax`. |
| 62 | +- The toggle label on all screens is "Set up in background". |
0 commit comments