Skip to content

Instantly share code, notes, and snippets.

@StewartLynch
Created February 27, 2026 23:20
Show Gist options
  • Select an option

  • Save StewartLynch/05a4b67bcd2c07c8f7a39c3cfad9a051 to your computer and use it in GitHub Desktop.

Select an option

Save StewartLynch/05a4b67bcd2c07c8f7a39c3cfad9a051 to your computer and use it in GitHub Desktop.
AppDelegate and SceneDelegate for SQLiteData Record Sharing - Gift Register app.
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions
) -> UISceneConfiguration {
let configuration = UISceneConfiguration(
name: "Default Configuration",
sessionRole: connectingSceneSession.role
)
configuration.delegateClass = SceneDelegate.self
return configuration
}
}
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
@Dependency(\.defaultSyncEngine) var syncEngine
var window: UIWindow?
func windowScene(
_ windowScene: UIWindowScene,
userDidAcceptCloudKitShareWith cloudKitShareMetadata: CKShare.Metadata
) {
Task {
try await syncEngine.acceptShare(metadata: cloudKitShareMetadata)
}
}
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
guard let cloudKitShareMetadata = connectionOptions.cloudKitShareMetadata
else { return }
Task {
try await syncEngine.acceptShare(metadata: cloudKitShareMetadata)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment