Created
February 27, 2026 23:20
-
-
Save StewartLynch/05a4b67bcd2c07c8f7a39c3cfad9a051 to your computer and use it in GitHub Desktop.
AppDelegate and SceneDelegate for SQLiteData Record Sharing - Gift Register app.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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