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.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
fix: APNs push token sync and launch performance
libokaic5508c21af8e
diff --git a/Codync-iOS/App/AppDelegate.swift b/Codync-iOS/App/AppDelegate.swiftindex c3c085bd..6800eff2 100644--- a/Codync-iOS/App/AppDelegate.swift+++ b/Codync-iOS/App/AppDelegate.swift@@ -15,7 +15,6 @@ final class AppDelegate: NSObject, UIApplicationDelegate {_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {- PremiumManager.shared.configure()application.registerForRemoteNotifications()NotificationCenter.default.addObserver(forName: UIApplication.didBecomeActiveNotification, object: nil, queue: .main) { [weak self] _ inTask { @MainActor in@@ -26,6 +25,7 @@ final class AppDelegate: NSObject, UIApplicationDelegate {}}Task {+ PremiumManager.shared.configure()async let startReceiver: () = receiver.start()async let loadPins: () = liveActivityManager.loadPinnedSessions()async let loadPref: () = liveActivityManager.loadPreference()diff --git a/Codync-iOS/Assets.xcassets/CodyncIcon.imageset/image 1.png b/Codync-iOS/Assets.xcassets/CodyncIcon.imageset/image 1.pngindex 3d6cf3c6..c83049c6 100644Binary files a/Codync-iOS/Assets.xcassets/CodyncIcon.imageset/image 1.png and b/Codync-iOS/Assets.xcassets/CodyncIcon.imageset/image 1.png differdiff --git a/Codync-iOS/Assets.xcassets/CodyncIcon.imageset/image 2.png b/Codync-iOS/Assets.xcassets/CodyncIcon.imageset/image 2.pngindex 3d6cf3c6..c83049c6 100644Binary files a/Codync-iOS/Assets.xcassets/CodyncIcon.imageset/image 2.png and b/Codync-iOS/Assets.xcassets/CodyncIcon.imageset/image 2.png differdiff --git a/Codync-iOS/Assets.xcassets/CodyncIcon.imageset/image.png b/Codync-iOS/Assets.xcassets/CodyncIcon.imageset/image.pngindex 3d6cf3c6..c83049c6 100644Binary files a/Codync-iOS/Assets.xcassets/CodyncIcon.imageset/image.png and b/Codync-iOS/Assets.xcassets/CodyncIcon.imageset/image.png differdiff --git a/Codync-iOS/Services/LiveActivityManager.swift b/Codync-iOS/Services/LiveActivityManager.swiftindex ac7a5792..b0e145da 100644--- a/Codync-iOS/Services/LiveActivityManager.swift+++ b/Codync-iOS/Services/LiveActivityManager.swift@@ -249,13 +249,24 @@ final class LiveActivityManager: ObservableObject {lastOverallState = nil}- // Pro upgrade: if we have an activity without push token, recreate it- if let activity = overallActivity, PremiumManager.shared.isPro, activity.pushToken == nil {- logger.info("Pro active but Overall Activity has no push token — recreating")- Task { await activity.end(nil, dismissalPolicy: .immediate) }- overallActivity = nil- lastOverallState = nil- pushTokenTasks["__overall__"]?.cancel()+ // Pro: ensure we're observing push token for existing activity+ if let activity = overallActivity, PremiumManager.shared.isPro {+ if activity.pushToken == nil && pushTokenTasks["__overall__"] == nil {+ // Activity exists but wasn't created with pushType: .token — recreate+ logger.info("Pro active but Overall Activity has no push token — recreating")+ Task { await activity.end(nil, dismissalPolicy: .immediate) }+ overallActivity = nil+ lastOverallState = nil+ } else if pushTokenTasks["__overall__"] == nil {+ // Activity has token but we're not observing — start observing + save existing token+ logger.info("Resuming push token observation for existing Overall Activity")+ observeOverallPushToken(activity: activity)+ if let token = activity.pushToken {+ let hex = token.map { String(format: "%02x", $0) }.joined()+ logger.info("Existing Overall push token: \(hex.prefix(8))...")+ Task { await savePushToken(sessionId: "__overall__", tokenHex: hex) }+ }+ }}let active = sortedSessions(sessions.filter { $0.status != .completed })@@ -476,11 +487,17 @@ final class LiveActivityManager: ObservableObject {recordName: "pushtoken-\(sessionId)",zoneID: CloudKitManager.zoneID)- let record = CKRecord(recordType: "PushToken", recordID: recordID)- record["sessionId"] = sessionId as CKRecordValue- record["token"] = tokenHex as CKRecordValue- record["updatedAt"] = Date() as CKRecordValuedo {+ // Fetch existing record or create new one (upsert)+ let record: CKRecord+ do {+ record = try await CloudKitManager.shared.database.record(for: recordID)+ } catch {+ record = CKRecord(recordType: "PushToken", recordID: recordID)+ }+ record["sessionId"] = sessionId as CKRecordValue+ record["token"] = tokenHex as CKRecordValue+ record["updatedAt"] = Date() as CKRecordValue_ = try await CloudKitManager.shared.database.save(record)logger.info("Saved push token to CloudKit for \(sessionId)")} catch {diff --git a/Codync-iOS/Services/PremiumManager.swift b/Codync-iOS/Services/PremiumManager.swiftindex 5fbb4108..8edc0c55 100644--- a/Codync-iOS/Services/PremiumManager.swift+++ b/Codync-iOS/Services/PremiumManager.swift@@ -9,18 +9,20 @@ private let logger = Logger(subsystem: "com.pokai.Codync.ios", category: "Premiufinal class PremiumManager {static let shared = PremiumManager()+ fileprivate(set) var isPro = false+ private(set) var isLoaded = false+#if DEBUG- /// Flip to `true` to test APNs push without a real subscription- fileprivate(set) var isPro = true+ /// When true, isPro is forced on and RevenueCat status is ignored+ fileprivate let debugForcesPro = true#else- fileprivate(set) var isPro = false+ fileprivate let debugForcesPro = false#endif- private(set) var isLoaded = falseprivate init() {}func configure() {- Purchases.logLevel = .verbose+ Purchases.logLevel = .warnPurchases.configure(withAPIKey: "REVENUECAT_API_KEY_REDACTED")Purchases.shared.delegate = RCPurchasesDelegate.sharedTask {@@ -29,6 +31,12 @@ final class PremiumManager {}func refreshStatus() async {+ if debugForcesPro {+ isPro = true+ isLoaded = true+ logger.info("Premium status: Pro (debug forced)")+ return+ }do {let info = try await Purchases.shared.customerInfo()isPro = info.entitlements["Codync Pro"]?.isActive == true@@ -41,6 +49,7 @@ final class PremiumManager {}func restorePurchases() async throws {+ if debugForcesPro { return }let info = try await Purchases.shared.restorePurchases()isPro = info.entitlements["Codync Pro"]?.isActive == truelogger.info("Restored purchases: \(self.isPro ? "Pro" : "Free")")@@ -55,7 +64,9 @@ private final class RCPurchasesDelegate: NSObject, RevenueCat.PurchasesDelegate,nonisolated func purchases(_ purchases: Purchases, receivedUpdated customerInfo: CustomerInfo) {let isPro = customerInfo.entitlements["Codync Pro"]?.isActive == trueTask { @MainActor in- PremiumManager.shared.isPro = isPro+ if !PremiumManager.shared.debugForcesPro {+ PremiumManager.shared.isPro = isPro+ }logger.info("Customer info updated: \(isPro ? "Pro" : "Free")")}}diff --git a/Codync-macOS/Services/APNsPushService.swift b/Codync-macOS/Services/APNsPushService.swiftindex 11e5a657..1de30504 100644--- a/Codync-macOS/Services/APNsPushService.swift+++ b/Codync-macOS/Services/APNsPushService.swift@@ -12,7 +12,8 @@ final class APNsPushService {private let workerURL = URL(string: "https://codync-push.kevin2005ha.workers.dev")!private let apiSecret = "f1bf65b18870dffc6c28e69d275413e9c08b33010cb652a781106aaaaf99f329"- private var pushTokens: [String: String] = [:] // sessionId → token hex+ private(set) var pushTokens: [String: String] = [:] // sessionId → token hex+ var tokenCount: Int { pushTokens.count }private var isFetchingTokens = falseprivate var lastTokenFetch: Date = .distantPast@@ -89,20 +90,25 @@ final class APNsPushService {// MARK: - Push Token Sync (from CloudKit)- func fetchPushTokens() async {+ func fetchPushTokens(sessionIds: [String] = []) async {guard !isFetchingTokens else { return }- guard Date().timeIntervalSince(lastTokenFetch) > 30 else { return }+ guard Date().timeIntervalSince(lastTokenFetch) > 10 else { return }isFetchingTokens = true- lastTokenFetch = Date() // Update even on failure to avoid spamming+ lastTokenFetch = Date()defer { isFetchingTokens = false }- let query = CKQuery(recordType: "PushToken", predicate: NSPredicate(value: true))+ // Fetch known push token records by ID (query requires indexing; direct fetch doesn't)+ var allIds = sessionIds+ if !allIds.contains("__overall__") { allIds.append("__overall__") }++ let recordIDs = allIds.map {+ CKRecord.ID(recordName: "pushtoken-\($0)", zoneID: CloudKitManager.zoneID)+ }+do {- let (results, _) = try await CloudKitManager.shared.database.records(- matching: query, inZoneWith: CloudKitManager.zoneID, resultsLimit: 20- )+ let recordResults = try await CloudKitManager.shared.database.records(for: recordIDs)var tokens: [String: String] = [:]- for (_, result) in results {+ for (_, result) in recordResults {guard case .success(let record) = result,let sessionId = record["sessionId"] as? String,let tokenHex = record["token"] as? String else { continue }@@ -110,13 +116,8 @@ final class APNsPushService {}if tokens != pushTokens {pushTokens = tokens- if !tokens.isEmpty {- logger.info("Fetched \(tokens.count) push tokens from CloudKit")- }+ logger.info("Fetched \(tokens.count) push tokens from CloudKit")}- } catch let error as CKError where error.code == .unknownItem {- // PushToken record type doesn't exist yet — iOS hasn't saved any tokens- logger.debug("No PushToken record type in CloudKit yet")} catch {logger.warning("Failed to fetch push tokens: \(error)")}diff --git a/Codync-macOS/Services/CloudKitSync.swift b/Codync-macOS/Services/CloudKitSync.swiftindex 72c7d9d0..6279f4e6 100644--- a/Codync-macOS/Services/CloudKitSync.swift+++ b/Codync-macOS/Services/CloudKitSync.swift@@ -111,7 +111,8 @@ final class CloudKitSync {}// Push to APNs via Worker relay for Live Activity background updates- await APNsPushService.shared.fetchPushTokens()+ await APNsPushService.shared.fetchPushTokens(sessionIds: sessions.map(\.sessionId))+ Self.log("APNs tokens: \(APNsPushService.shared.tokenCount)")// Individual mode: per-session pushfor session in toSave {await APNsPushService.shared.sendUpdate(session: session)