@bsv/expo-wallet-toolbox 0.11.8 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -158,6 +158,13 @@ function loadQRCode(): QRCodeComponent {
158
158
  */
159
159
  const INBOX_POLL_MS = 5000
160
160
 
161
+ /**
162
+ * While the live socket is up the satoshi inbox is only re-read on every Nth
163
+ * poll tick: the socket tells us the moment something lands, so the poll is the
164
+ * safety net for a missed event, not the delivery path.
165
+ */
166
+ const LIVE_SATOSHI_POLL_EVERY = 3
167
+
161
168
  // ── Needs attention ──────────────────────────────────────────────────────────
162
169
  //
163
170
  // Replaces the old accept list. An arriving payment is credited automatically
@@ -444,6 +451,8 @@ export default function HandleReceive({
444
451
 
445
452
  /** One inbox read at a time — see fetchPayments. */
446
453
  const fetchingRef = useRef(false)
454
+ /** A live payment arrived mid-read: read once more when that read finishes. */
455
+ const rereadRef = useRef(false)
447
456
  /** The live attempt map, for discard copy that must not close over stale state. */
448
457
  const attemptsRef = useRef<Record<string, InboxAttempt>>({})
449
458
  useEffect(() => {
@@ -482,7 +491,7 @@ export default function HandleReceive({
482
491
  }, [identityKey, loadIdentityKey])
483
492
  )
484
493
 
485
- const peerPayClient = useMemo<PeerPayClient | null>(() => {
494
+ const newPeerPayClient = useCallback((): PeerPayClient | null => {
486
495
  if (!isConfigured || !messageBoxUrl || !wallet) return null
487
496
  try {
488
497
  return new PeerPayClient({
@@ -494,6 +503,8 @@ export default function HandleReceive({
494
503
  return null
495
504
  }
496
505
  }, [isConfigured, messageBoxUrl, wallet, adminOriginator])
506
+ /** The client every inbox read, accept and discard goes through. */
507
+ const peerPayClient = useMemo(() => newPeerPayClient(), [newPeerPayClient])
497
508
 
498
509
  // BRC-125 with this app's url extension: the payer learns where to deliver
499
510
  // without an overlay lookup. Omitted when no server is configured, since
@@ -588,13 +599,19 @@ export default function HandleReceive({
588
599
  )
589
600
 
590
601
  const fetchPayments = useCallback(
591
- async (options: { silent?: boolean } = {}) => {
602
+ async (options: { silent?: boolean; queueIfBusy?: boolean } = {}) => {
592
603
  const client = peerPayClient
593
604
  if (!client || !messageBoxUrl || messageBoxUrl === NO_MESSAGE_BOX) return
594
605
  // One read at a time. The poll, the refresh button and every accept all
595
606
  // reach this, and two overlapping reads can land out of order — the older
596
607
  // response winning would resurrect a row that was just internalized.
597
- if (fetchingRef.current) return
608
+ if (fetchingRef.current) {
609
+ // A live payment must not be dropped here: the read in flight may have
610
+ // listed the inbox before it landed, and the poll is slow while the
611
+ // socket is up. Run one more read when this one finishes.
612
+ if (options.queueIfBusy) rereadRef.current = true
613
+ return
614
+ }
598
615
  fetchingRef.current = true
599
616
  try {
600
617
  const outcome = await runCredit()
@@ -614,6 +631,10 @@ export default function HandleReceive({
614
631
  }
615
632
  } finally {
616
633
  fetchingRef.current = false
634
+ if (rereadRef.current) {
635
+ rereadRef.current = false
636
+ void fetchRef.current({ silent: true })
637
+ }
617
638
  }
618
639
  },
619
640
  [peerPayClient, messageBoxUrl, wallet, adminOriginator, t, runCredit]
@@ -668,22 +689,120 @@ export default function HandleReceive({
668
689
  tokenTickRef.current = tokenTick
669
690
  }, [tokenTick])
670
691
 
671
- // ── Poll the inbox ──
692
+ // ── Watch the inbox ──
693
+ //
694
+ // While someone is actually looking at this screen, a MessageBox WebSocket
695
+ // tells us the moment a payment lands, and a poll backs it up. The socket is
696
+ // the fast path; the poll covers a listener that could not start, a socket
697
+ // that dropped without telling us, and everything the socket does not carry
698
+ // (the Mandala token inbox has no live channel). Only the satoshi read
699
+ // slows while the socket is up — the token drain stays on the 5s tick.
672
700
  //
673
- // A payment arrives whenever the sender's wallet delivers it and MessageBox has
674
- // no push channel here, so "it appears on its own" means polling — but only
675
- // while someone is actually looking at this screen. Unmount and blur stop it
676
- // because a poll nobody can see spends battery; a backgrounded app stops it
677
- // for the same reason and because iOS will suspend the timer anyway. The
678
- // shared creditInboxOnce mutex serializes with TaskCreditInbox.
701
+ // Both run only while the screen is focused and the app active. Blur and
702
+ // background disconnect the socket (a backgrounded app cannot hold one, and
703
+ // one that looked alive on return would quietly slow the poll for nothing),
704
+ // and coming back to the foreground re-listens and reads at once. The
705
+ // callback never credits anything itself: it only triggers the same read the
706
+ // poll does, so there is one crediting path and the shared creditInboxOnce
707
+ // mutex still serializes with TaskCreditInbox.
708
+ //
709
+ // Each listening session gets its OWN short-lived client, never the one the
710
+ // reads use. A MessageBoxClient remembers the rooms it joined across a
711
+ // disconnect, so a second listen on the same instance authenticates a fresh
712
+ // socket but never re-joins the room: listenForLivePayments would resolve,
713
+ // the poll would slow, and no push would ever arrive. A new instance starts
714
+ // with no rooms, no half-finished connection attempt and no socket, and
715
+ // throwing it away on stop discards all three.
716
+ //
717
+ // Blur is a ref, not state, so the interval notices it (within one tick)
718
+ // rather than this effect re-running; the effect itself restarts only with
719
+ // the client.
679
720
  useEffect(() => {
680
721
  if (!peerPayClient) return
681
722
  let cancelled = false
723
+ /** A session is starting, up, or has failed and is not to be retried yet. */
724
+ let listening = false
725
+ /** The current session's client, while one is open. */
726
+ let sessionClient: PeerPayClient | null = null
727
+ /** The socket is confirmed up — the only state in which the poll slows. */
728
+ let live = false
729
+ /** Bumped on every stop so a late start result cannot revive a dead session. */
730
+ let generation = 0
731
+ /** Poll ticks since the socket came up, for the slow satoshi cadence. */
732
+ let liveTicks = 0
733
+
734
+ const visible = () => !cancelled && focusedRef.current && AppState.currentState === 'active'
735
+
736
+ const readSatoshiInbox = (queueIfBusy = false) => {
737
+ void fetchRef.current({ silent: true, queueIfBusy })
738
+ }
739
+
740
+ /** Close a session's socket. Safe to repeat and on a session that never connected. */
741
+ const closeSession = (session: PeerPayClient) => {
742
+ void session.disconnectWebSocket().catch(() => {})
743
+ }
744
+
745
+ const startListener = () => {
746
+ if (listening) return
747
+ listening = true
748
+ const mine = ++generation
749
+ const session = newPeerPayClient()
750
+ if (!session) {
751
+ console.warn('[pay] live inbox listener unavailable: client not created')
752
+ return
753
+ }
754
+ sessionClient = session
755
+ void (async () => {
756
+ try {
757
+ // The session client is built with this same MessageBox host, so no
758
+ // overrideHost: the socket goes where the inbox reads go.
759
+ await session.listenForLivePayments({
760
+ onPayment: () => {
761
+ if (mine === generation && visible()) readSatoshiInbox(true)
762
+ }
763
+ })
764
+ if (mine === generation) {
765
+ live = true
766
+ liveTicks = 0
767
+ } else {
768
+ // Stopped while it was still connecting. The stop could not close a
769
+ // socket that did not exist yet, so close it now it does.
770
+ closeSession(session)
771
+ }
772
+ } catch (error: any) {
773
+ // Whatever half-open socket the failed attempt left would otherwise
774
+ // keep retrying in the background.
775
+ closeSession(session)
776
+ if (mine !== generation) return
777
+ live = false
778
+ sessionClient = null
779
+ // `listening` stays set so a failed start is not retried every tick;
780
+ // the next blur or background resets it. Full 5s polling carries on.
781
+ console.warn(`[pay] live inbox listener unavailable: ${error?.message || 'unknown error'}`)
782
+ }
783
+ })()
784
+ }
785
+
786
+ const stopListener = () => {
787
+ if (!listening) return
788
+ listening = false
789
+ live = false
790
+ generation++
791
+ const session = sessionClient
792
+ sessionClient = null
793
+ if (session) closeSession(session)
794
+ }
795
+
796
+ /** Listen exactly while the screen can be seen. */
797
+ const syncListener = () => {
798
+ if (visible()) startListener()
799
+ else stopListener()
800
+ }
682
801
 
683
802
  const tick = () => {
684
- if (cancelled || !focusedRef.current) return
685
- if (AppState.currentState !== 'active') return
686
- void fetchRef.current({ silent: true })
803
+ syncListener()
804
+ if (!visible()) return
805
+ if (!live || ++liveTicks % LIVE_SATOSHI_POLL_EVERY === 0) readSatoshiInbox()
687
806
  // The token inbox is a SIBLING drain, not a widened one: Mandala delivers
688
807
  // to its own message box and the two never meet. Same 5s focused tick,
689
808
  // because a payee standing in front of this screen expects both kinds of
@@ -691,19 +810,25 @@ export default function HandleReceive({
691
810
  void tokenTickRef.current()
692
811
  }
693
812
 
813
+ syncListener()
694
814
  const interval = setInterval(tick, INBOX_POLL_MS)
695
815
  // Returning to the app should show what arrived while it was away, rather
696
- // than waiting out the rest of an interval.
816
+ // than waiting out the rest of an interval — both inboxes, whatever point
817
+ // the slow cadence had reached.
697
818
  const appSubscription = AppState.addEventListener('change', next => {
698
- if (next === 'active') tick()
819
+ syncListener()
820
+ if (next !== 'active' || !visible()) return
821
+ readSatoshiInbox()
822
+ void tokenTickRef.current()
699
823
  })
700
824
 
701
825
  return () => {
702
826
  cancelled = true
703
827
  clearInterval(interval)
704
828
  appSubscription.remove()
829
+ stopListener()
705
830
  }
706
- }, [peerPayClient])
831
+ }, [peerPayClient, newPeerPayClient])
707
832
 
708
833
  /** Retry one row that had given up. Runs the whole pass, forcing this id. */
709
834
  const handleRetry = useCallback(
@@ -0,0 +1,124 @@
1
+ /**
2
+ * One-time heads-up shown the first time the user picks "Share remote link" on
3
+ * "Get paid", before the OS asks to allow notifications. Same rationale as
4
+ * NearbyAdvisoryModal and BiometricAdvisoryModal: never let an OS permission
5
+ * dialog be the user's first signal that something is about to happen — say
6
+ * what it is for, briefly, first.
7
+ *
8
+ * The OS prompt is fired only on Continue. Either button records that the
9
+ * advisory was shown, and neither blocks the link flow underneath.
10
+ */
11
+ import React from 'react'
12
+ import { Modal, Platform, Pressable, StyleSheet, Text, View } from 'react-native'
13
+ import { useTheme, spacing, radii, typography, i18n } from '@bsv/expo-wallet-toolbox'
14
+ import PressableScale from '../ui/PressableScale'
15
+
16
+ const t = (k: string, o?: Record<string, unknown>) => i18n.t(k, o) as string
17
+
18
+ type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
19
+ let ioniconsComponent: IoniconsComponent | undefined
20
+ function loadIonicons(): IoniconsComponent {
21
+ if (!ioniconsComponent) {
22
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
23
+ ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
24
+ }
25
+ return ioniconsComponent
26
+ }
27
+
28
+ /**
29
+ * Whether the advisory should be on screen. Pure so the gating is testable
30
+ * without rendering the screen: only on the remote-link method, only once per
31
+ * device, and only while the OS would still ask (granted/denied are final, and
32
+ * `null` means the state has not loaded yet — show nothing rather than flash).
33
+ */
34
+ export function shouldShowNotificationAdvisory(s: {
35
+ method: string | null
36
+ advisorySeen: boolean | null
37
+ permission: 'granted' | 'denied' | 'undetermined' | null
38
+ }): boolean {
39
+ return s.method === 'get-handle' && s.advisorySeen === false && s.permission === 'undetermined'
40
+ }
41
+
42
+ export const NotificationAdvisoryModal: React.FC<{
43
+ visible: boolean
44
+ onNotNow: () => void
45
+ onContinue: () => void
46
+ }> = ({ visible, onNotNow, onContinue }) => {
47
+ const { colors } = useTheme()
48
+ const Ionicons = loadIonicons()
49
+
50
+ if (!visible) return null
51
+
52
+ return (
53
+ <Modal
54
+ transparent
55
+ visible
56
+ animationType="fade"
57
+ onRequestClose={onNotNow}
58
+ statusBarTranslucent={Platform.OS === 'android'}
59
+ navigationBarTranslucent={Platform.OS === 'android'}
60
+ >
61
+ <View style={[styles.backdrop, { backgroundColor: colors.scrim }]}>
62
+ <Pressable
63
+ style={StyleSheet.absoluteFill}
64
+ onPress={onNotNow}
65
+ accessible={true}
66
+ accessibilityRole="button"
67
+ accessibilityLabel="Close"
68
+ accessibilityHint="Dismisses this advisory"
69
+ />
70
+ <View style={[styles.card, { backgroundColor: colors.sheetBackground, borderColor: colors.separator }]}>
71
+ <View style={[styles.heroIcon, { backgroundColor: colors.fillTertiary }]}>
72
+ <Ionicons name="notifications-outline" size={26} color={colors.accent} />
73
+ </View>
74
+ <Text style={[styles.title, { color: colors.textPrimary }]}>{t('push_advisory_title')}</Text>
75
+ <Text style={[styles.body, { color: colors.textSecondary }]}>{t('push_advisory_body')}</Text>
76
+
77
+ <PressableScale
78
+ haptic="confirm"
79
+ onPress={onContinue}
80
+ style={[styles.primary, { backgroundColor: colors.accent }]}
81
+ >
82
+ <Text style={[styles.primaryLabel, { color: colors.textOnAccent }]}>{t('push_advisory_continue')}</Text>
83
+ </PressableScale>
84
+
85
+ <PressableScale haptic="tap" onPress={onNotNow} style={styles.secondary}>
86
+ <Text style={[styles.secondaryLabel, { color: colors.textSecondary }]}>{t('push_advisory_not_now')}</Text>
87
+ </PressableScale>
88
+ </View>
89
+ </View>
90
+ </Modal>
91
+ )
92
+ }
93
+
94
+ const styles = StyleSheet.create({
95
+ backdrop: { flex: 1, alignItems: 'center', justifyContent: 'center', paddingHorizontal: spacing.xl },
96
+ card: {
97
+ width: '100%',
98
+ maxWidth: 360,
99
+ borderRadius: radii.xl,
100
+ borderWidth: StyleSheet.hairlineWidth,
101
+ padding: spacing.xl,
102
+ alignItems: 'center',
103
+ gap: spacing.md
104
+ },
105
+ heroIcon: {
106
+ width: 56,
107
+ height: 56,
108
+ borderRadius: 28,
109
+ alignItems: 'center',
110
+ justifyContent: 'center',
111
+ marginBottom: spacing.xs
112
+ },
113
+ title: { ...typography.title2, textAlign: 'center' },
114
+ body: { ...typography.subhead, textAlign: 'center', marginBottom: spacing.sm },
115
+ primary: {
116
+ width: '100%',
117
+ borderRadius: radii.md,
118
+ paddingVertical: spacing.lg,
119
+ alignItems: 'center'
120
+ },
121
+ primaryLabel: { ...typography.headline },
122
+ secondary: { paddingVertical: spacing.sm, alignItems: 'center' },
123
+ secondaryLabel: { ...typography.body }
124
+ })
package/ui/index.ts CHANGED
@@ -59,6 +59,7 @@ export { default as HandleReceive } from './components/pay/HandleReceive'
59
59
  export { useMessageBoxConfig, ConfigPanel } from './components/pay/MessageBoxConfig'
60
60
  export { default as NearbyFlow, type NearbyFlowProps } from './components/pay/NearbyFlow'
61
61
  export { NearbyAdvisoryModal } from './components/pay/NearbyAdvisoryModal'
62
+ export { NotificationAdvisoryModal } from './components/pay/NotificationAdvisoryModal'
62
63
  export { default as OfflineNotice, offlineActionDetails, type OfflineNoticeProps } from './components/pay/OfflineNotice'
63
64
  export { default as PayCellRow, type PayCellRowProps } from './components/pay/PayCellRow'
64
65
  export {
@@ -46,6 +46,9 @@ import { useAssetStatus, useMandala } from '../hooks/useMandala'
46
46
  import { formatTokenAmountWithUnit } from '../tokenFormat'
47
47
  import { nearbyAdvisory } from '../../core/localpay/nearbyAdvisory'
48
48
  import { NearbyAdvisoryModal } from '../components/pay/NearbyAdvisoryModal'
49
+ import { pushAdvisory } from '../../core/push/pushAdvisory'
50
+ import { getPushAdapter } from '../../core/toolboxConfig'
51
+ import { NotificationAdvisoryModal, shouldShowNotificationAdvisory } from '../components/pay/NotificationAdvisoryModal'
49
52
  import type { DismissTarget } from '../dismissTarget'
50
53
 
51
54
  /**
@@ -298,6 +301,35 @@ export function PayScreen({ dismissTo = '/' }: PayScreenProps = {}) {
298
301
  }, [])
299
302
  const isNearbyCell = (direction === 'pay' && nearbySession !== null) || method === 'get-nearby'
300
303
 
304
+ // ── notification advisory ───────────────────────────────────────────
305
+ /**
306
+ * The first time the user picks "Share remote link", the OS will be asked to
307
+ * allow notifications (so a payment can reach them while the app is in the
308
+ * background). The advisory goes first, over the link flow — which keeps
309
+ * mounting underneath and never waits on the answer. null = not loaded yet
310
+ * (show nothing rather than flash it at a returning user); both stay null
311
+ * until the user first lands on the remote-link method.
312
+ */
313
+ const [pushAdvisorySeen, setPushAdvisorySeen] = useState<boolean | null>(null)
314
+ const [pushPermission, setPushPermission] = useState<'granted' | 'denied' | 'undetermined' | null>(null)
315
+ useEffect(() => {
316
+ if (method !== 'get-handle' || pushAdvisorySeen !== null) return
317
+ let cancelled = false
318
+ const adapter = getPushAdapter()
319
+ void Promise.all([pushAdvisory.get(), adapter ? adapter.getPermission() : Promise.resolve(null)])
320
+ .then(([seen, perm]) => {
321
+ if (cancelled) return
322
+ setPushAdvisorySeen(seen)
323
+ setPushPermission(perm)
324
+ })
325
+ .catch(() => {
326
+ // Advisory only: a host adapter that cannot report its permission just means no modal.
327
+ })
328
+ return () => {
329
+ cancelled = true
330
+ }
331
+ }, [method, pushAdvisorySeen])
332
+
301
333
  // Refreshed whenever the wallet finishes building, connectivity changes, or
302
334
  // the user enters/leaves a method or a nearby session: the queue only moves
303
335
  // when the network state does or when one of those just queued a row (e.g.
@@ -595,6 +627,27 @@ export function PayScreen({ dismissTo = '/' }: PayScreenProps = {}) {
595
627
  setNearbyAdvisorySeen(true)
596
628
  }}
597
629
  />
630
+ <NotificationAdvisoryModal
631
+ visible={shouldShowNotificationAdvisory({
632
+ method,
633
+ advisorySeen: pushAdvisorySeen,
634
+ permission: pushPermission
635
+ })}
636
+ onNotNow={() => {
637
+ void pushAdvisory.set()
638
+ setPushAdvisorySeen(true)
639
+ }}
640
+ onContinue={() => {
641
+ void pushAdvisory.set()
642
+ setPushAdvisorySeen(true)
643
+ void getPushAdapter()
644
+ ?.requestPermission()
645
+ .then(setPushPermission)
646
+ .catch(() => {
647
+ // The link flow does not depend on the answer; Task 7's sync reads the permission itself.
648
+ })
649
+ }}
650
+ />
598
651
  </View>
599
652
  )
600
653
  }
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useEffect, useCallback } from 'react'
2
- import { View, Text, ScrollView, StyleSheet } from 'react-native'
2
+ import { View, Text, ScrollView, StyleSheet, AppState } from 'react-native'
3
3
  import { useTranslation } from 'react-i18next'
4
4
  import { useTheme, spacing, typography, useWallet, isVaultAvailable, useVault } from '@bsv/expo-wallet-toolbox'
5
5
  import { GroupedSection } from '../components/ui/GroupedList'
@@ -7,6 +7,9 @@ import { ListRow } from '../components/ui/ListRow'
7
7
  import AmountDisplay from '../components/wallet/AmountDisplay'
8
8
  import { sdk } from '@bsv/wallet-toolbox-mobile'
9
9
  import AsyncStorage from '@react-native-async-storage/async-storage'
10
+ import { pushAdvisory } from '../../core/push/pushAdvisory'
11
+ import type { PushPermission } from '../../core/push/types'
12
+ import { getPushAdapter } from '../../core/toolboxConfig'
10
13
 
11
14
  /**
12
15
  * expo-router is required lazily rather than imported at module scope: this
@@ -31,7 +34,9 @@ const CACHE_DURATION = 30000
31
34
  export function SettingsScreen() {
32
35
  const { t } = useTranslation()
33
36
  const { colors } = useTheme()
34
- const { router } = loadExpoRouter()
37
+ // `useFocusEffect` is a hook, but calling it through the lazy loader is
38
+ // equivalent to a direct import (same as WalletHomeScreen/PayScreen).
39
+ const { router, useFocusEffect } = loadExpoRouter()
35
40
  const { managers, adminOriginator, selectedNetwork, txStatusVersion } = useWallet()
36
41
 
37
42
  // Read during render, from the reactive network, so the row disappears on a
@@ -110,6 +115,57 @@ export function SettingsScreen() {
110
115
  refreshBalance()
111
116
  }, [txStatusVersion, refreshBalance])
112
117
 
118
+ // Payment notifications. The row exists only when the host wired a push
119
+ // adapter, and it is the one place besides the "Share remote link" advisory
120
+ // that can trigger the OS permission prompt.
121
+ const pushAdapter = getPushAdapter()
122
+ const [pushPermission, setPushPermission] = useState<PushPermission | null>(null)
123
+ const refreshPushPermission = useCallback(async () => {
124
+ if (!pushAdapter) return
125
+ try {
126
+ const next = await pushAdapter.getPermission()
127
+ // A re-read never walks 'denied' back to 'undetermined'. Android reports
128
+ // every not-granted state as 'undetermined', and the OS dialog's own
129
+ // dismissal brings the app back to 'active' right after a denial, so an
130
+ // unguarded read would erase the denial and leave the next press
131
+ // re-requesting (a silent no-op once the OS stops prompting) instead of
132
+ // opening the OS settings. A later 'granted' still replaces 'denied'.
133
+ setPushPermission(prev => (prev === 'denied' && next === 'undetermined' ? prev : next))
134
+ } catch {
135
+ // Leave the last known state; the row stays usable.
136
+ }
137
+ }, [pushAdapter])
138
+ useFocusEffect(
139
+ useCallback(() => {
140
+ void refreshPushPermission()
141
+ }, [refreshPushPermission])
142
+ )
143
+ // Coming back from the OS notification settings does not refocus this
144
+ // screen, so re-read when the app returns to the foreground.
145
+ useEffect(() => {
146
+ if (!pushAdapter) return
147
+ const subscription = AppState.addEventListener('change', state => {
148
+ if (state === 'active') void refreshPushPermission()
149
+ })
150
+ return () => subscription.remove()
151
+ }, [pushAdapter, refreshPushPermission])
152
+
153
+ const onPushPress = useCallback(async () => {
154
+ if (!pushAdapter) return
155
+ try {
156
+ if (pushPermission === 'undetermined') {
157
+ await pushAdvisory.set()
158
+ // Take the answer as given rather than re-reading it (see the guard
159
+ // in refreshPushPermission for why a denial must stick).
160
+ setPushPermission(await pushAdapter.requestPermission())
161
+ } else {
162
+ await pushAdapter.openSettings()
163
+ }
164
+ } catch {
165
+ // The adapter is host code; a failed call leaves the row as it was.
166
+ }
167
+ }, [pushAdapter, pushPermission])
168
+
113
169
  return (
114
170
  <View style={{ backgroundColor: colors.backgroundSecondary }}>
115
171
  <ScrollView contentContainerStyle={{ paddingBottom: spacing.xxxl }}>
@@ -158,6 +214,20 @@ export function SettingsScreen() {
158
214
  )}
159
215
  </GroupedSection>
160
216
 
217
+ {/* ── Notifications ── */}
218
+ {pushAdapter && (
219
+ <GroupedSection header={t('notifications')}>
220
+ <ListRow
221
+ label={t('push_settings_row')}
222
+ icon="notifications-outline"
223
+ iconColor={colors.accent}
224
+ value={pushPermission === 'granted' ? t('push_settings_on') : t('push_settings_off')}
225
+ onPress={onPushPress}
226
+ isLast
227
+ />
228
+ </GroupedSection>
229
+ )}
230
+
161
231
  {/* ── Settings drill-down ── */}
162
232
  <GroupedSection>
163
233
  <ListRow