Commit d5499b57f6

d5499b57f604316d70dca6dcbbbcbd1e25bdadf9

parent: 887f90d8f2

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-20 23:57 UTC

push: ask for a token when permission is granted in Settings

registerForRemoteNotifications was reached only from the toggle's
notDetermined branch and from launch. A user who tapped "Don't Allow",
then enabled notifications in Settings and turned the toggle on, set
the server preference and never asked iOS for a token: no device add
was sent and push stayed dead until the next cold launch, with the UI
reporting it as on.

Register on the scene activation that first reports .authorized, which
is the Settings round trip the denied row sends the user on. It is
idempotent; device add upserts.

Ref krz/gitbay#89

Layout: unified · split

gitbay/Views/Account/NotificationsView.swift +11 −1
@@ -64,7 +64,17 @@ struct NotificationsView: View {
64 // switch there. 64 // switch there.
65 .onChange(of: scenePhase) { _, newPhase in 65 .onChange(of: scenePhase) { _, newPhase in
66 guard newPhase == .active else { return } 66 guard newPhase == .active else { return }
67 Task { authorization = await registrar.authorizationStatus() } 67 Task {
68 let status = await registrar.authorizationStatus()
69 // Granting in Settings is the one route to .authorized
70 // that never passes through the toggle, so it is also
71 // the one route that never asks iOS for a device
72 // token. Without this the toggle turns on, the server
73 // preference is set, and no `device add` is ever sent.
74 let justGranted = status == .authorized && authorization != .authorized
75 authorization = status
76 if justGranted { await registrar.registerIfAlreadyAuthorized() }
77 }
68 } 78 }
69 .refreshable { 79 .refreshable {
70 await model.load() 80 await model.load()