listless

A simple list app for Apple platforms
Log | Files | Refs | README | LICENSE

commit fe6dca8a2e39d5af0e8b0a91d915b922cbd42980
parent 0956d98718d42cd2338c775028a21629a0ba0769
Author: Michael Camilleri <[email protected]>
Date:   Sat,  4 Apr 2026 14:10:09 +0900

Support background syncing using push notifications

Prior to this commit, iCloud syncing would only happen while the app was
open and had focus. This commit uses CloudKit silent pushes. However, it
is noted that this API is broken in the 26.4 versions of Apple's OSs and
so this will not change behaviour for users on those versions.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

Diffstat:
MListlessMac/ListlessMacApp.swift | 10++++++++++
MListlessiOS/ListlessiOSApp.swift | 16++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/ListlessMac/ListlessMacApp.swift b/ListlessMac/ListlessMacApp.swift @@ -44,10 +44,20 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation { NSWindow.allowsAutomaticWindowTabbing = false applyAppearanceMode(UserDefaults.standard.integer(forKey: Self.appearanceModeKey)) keyValueSyncBridge.start() + NSApplication.shared.registerForRemoteNotifications() installMainMenu() openNewWindow() } + func application( + _ application: NSApplication, + didReceiveRemoteNotification userInfo: [String: Any] + ) { + // NSPersistentCloudKitContainer handles the sync internally; + // implementing this delegate method ensures macOS delivers the + // silent push to this process. + } + func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool { if !flag { diff --git a/ListlessiOS/ListlessiOSApp.swift b/ListlessiOS/ListlessiOSApp.swift @@ -3,6 +3,22 @@ import SwiftUI // MARK: - App Delegate class IOSAppDelegate: UIResponder, UIApplicationDelegate { + func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil + ) -> Bool { + application.registerForRemoteNotifications() + return true + } + + func application( + _ application: UIApplication, + didReceiveRemoteNotification userInfo: [AnyHashable: Any], + fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void + ) { + completionHandler(.newData) + } + override func buildMenu(with builder: UIMenuBuilder) { guard builder.system == .main else { super.buildMenu(with: builder)