Jun 24 - Implement device registry
This commit is contained in:
@@ -42,6 +42,13 @@ struct ContentView: View {
|
||||
// any failure (offline, parse error, etc.) so it never disrupts
|
||||
// normal app use.
|
||||
await updateChecker.checkForUpdate()
|
||||
// 5. Register device now that auth is fully resolved.
|
||||
// The .onChange(scenePhase == .active) fires BEFORE restoreSession()
|
||||
// completes on first launch, so auth.isAuthenticated is false there
|
||||
// and registration is skipped. This call covers that gap.
|
||||
if AuthManager.shared.isAuthenticated {
|
||||
await APIClient.shared.registerDevice()
|
||||
}
|
||||
}
|
||||
// Stop the 60s notification poll when the app goes to background and
|
||||
// restart it when it returns to the foreground. iOS suspends Tasks
|
||||
@@ -60,6 +67,11 @@ struct ContentView: View {
|
||||
SyncManager.shared.suspendPolling()
|
||||
case .active:
|
||||
SyncManager.shared.resumePolling()
|
||||
// Register / update device record on every foreground.
|
||||
// Fire-and-forget — auth guard is inside registerDevice().
|
||||
if auth.isAuthenticated {
|
||||
Task { await APIClient.shared.registerDevice() }
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user