Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

fix: foreground polling on launch, force silent push fetch

libokaid593e2581017
diff --git a/Codync-iOS/App/AppDelegate.swift b/Codync-iOS/App/AppDelegate.swift
index ac60b911..839f69c5 100644
--- a/Codync-iOS/App/AppDelegate.swift
+++ b/Codync-iOS/App/AppDelegate.swift
@@ -9,6 +9,7 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
let receiver = CloudKitReceiver()
let liveActivityManager = LiveActivityManager()
let primarySessionManager = PrimarySessionManager()
+ private var pollTimer: Timer?
func application(
_ application: UIApplication,
@@ -28,10 +29,33 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
let center = UNUserNotificationCenter.current()
_ = try? await center.requestAuthorization(options: [.alert, .sound, .badge])
+
+ startForegroundPolling()
}
return true
}
+ // MARK: - Foreground Polling
+
+ func startForegroundPolling() {
+ pollTimer?.invalidate()
+ pollTimer = Timer.scheduledTimer(withTimeInterval: 10, repeats: true) { [weak self] _ in
+ Task { @MainActor in
+ guard let self else { return }
+ await self.receiver.fetch(source: "poll", force: true)
+ self.liveActivityManager.userPrimarySessionId = self.primarySessionManager.primarySessionId
+ self.liveActivityManager.updateSessions(self.receiver.sessions)
+ self.primarySessionManager.autoSelect(from: self.receiver.sessions)
+ }
+ }
+ RunLoop.main.add(pollTimer!, forMode: .common)
+ }
+
+ func stopForegroundPolling() {
+ pollTimer?.invalidate()
+ pollTimer = nil
+ }
+
func application(
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
@@ -60,7 +84,7 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
fmt.dateFormat = "HH:mm:ss"
let ts = fmt.string(from: Date())
logger.info("[\(ts)] CloudKit push received")
- await receiver.fetch(source: "silent-push")
+ await receiver.fetch(source: "silent-push", force: true)
let statuses = receiver.sessions.map { "\($0.projectName):\($0.status.rawValue)" }.joined(separator: ", ")
logger.info("[\(ts)] → \(statuses)")
liveActivityManager.updateSessions(receiver.sessions)
diff --git a/Codync-iOS/App/CodyncIOSApp.swift b/Codync-iOS/App/CodyncIOSApp.swift
index 98134fa5..94cb23a0 100644
--- a/Codync-iOS/App/CodyncIOSApp.swift
+++ b/Codync-iOS/App/CodyncIOSApp.swift
@@ -17,16 +17,18 @@ struct CodyncIOSApp: App {
.onChange(of: scenePhase) { _, phase in
if phase == .active {
appDelegate.liveActivityManager.ensureTimerRunning()
- // Force push current state immediately (isDark, duration, etc.)
appDelegate.liveActivityManager.invalidateCache()
appDelegate.liveActivityManager.userPrimarySessionId = appDelegate.primarySessionManager.primarySessionId
appDelegate.liveActivityManager.updateSessions(appDelegate.receiver.sessions)
- // Then fetch fresh data from CloudKit
+ // Fetch fresh + start polling while in foreground
Task {
await appDelegate.receiver.fetch(source: "foreground-return", force: true)
appDelegate.liveActivityManager.updateSessions(appDelegate.receiver.sessions)
appDelegate.primarySessionManager.autoSelect(from: appDelegate.receiver.sessions)
}
+ appDelegate.startForegroundPolling()
+ } else if phase == .background {
+ appDelegate.stopForegroundPolling()
}
}
}