Post

Replies

Boosts

Views

Activity

Cannot Accept CloudKit Share After First App Install
I have an iOS app (1Address) which allows users to share their address with family and friends using CloudKit Sharing. Users share their address record (CKRecord) via a share link/url which when tapped allows the receiving user to accept the share and have a persistent view into the sharing user's address record (CKShare). However, most users when they recieve a sharing link do not have the app installed yet, and so when a new receiving user taps the share link, it prompts them to download the app from the app store. After the new user downloads the app from the app store and opens the app, my understanding is that the system (iOS) will/should then vend to my app the previously tapped cloudKitShareMetadata (or share url), however, this metadata is not being vended by the system. This forces the user to re-tap the share link and leads to some users thinking the app doesn't work or not completing the sharing / onboarding flow. Is there a workaround or solve for this that doesn't require the user to tap the share link a second time? In my scene delegate I am implementing: func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {...} And also func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {...} And also: func windowScene(_ windowScene: UIWindowScene, userDidAcceptCloudKitShareWith cloudKitShareMetadata: CKShare.Metadata) {...} And: func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {...} Unfortunately, none of these are called or passed metadata on the initial app run after install. Only after the user goes back and taps a link again can they accept the share. This documentation: https://developer.apple.com/documentation/cloudkit/ckshare says that adding the CKSharingSupported key to your app's Info.plist file allows the system to launch your app when a user taps or clicks a share URL, but it does not clarify what should happen if your app is being installed for the first time. This seems to imply that the system is holding onto the share metadata and/or url, but for some reason it is not being vended to the app on first run. Open to any ideas here for how to fix and I also filed feedback: FB20934189.
2
1
123
1w
Persisting User Settings with SwiftData
I was wondering what the recommended way is to persist user settings with SwiftData? It seems the SwiftData API is focused around querying for multiple objects, but what if you just want one UserSettings object that is persisted across devices say for example to store the user's age or sorting preferences. Do we just create one object and then query for it or is there a better way of doing this? Right now I am just creating: import SwiftData @Model final class UserSettings { var age: Int = 0 var sortAtoZ: Bool = true init(age: Int = 0, sortAtoZ: Bool = true) { self.age = age self.sortAtoZ = sortAtoZ } } In my view I am doing as follows: import SwiftUI import SwiftData struct SettingsView: View { @Environment(\.modelContext) var context @Query var settings: [UserSettings] var body: some View { ForEach(settings) { setting in let bSetting = Bindable(setting) Toggle("Sort A-Z", isOn: bSetting.sortAtoZ) TextField("Age", value: bSetting.age, format: .number) } .onAppear { if settings.isEmpty { context.insert(UserSettings(age: 0, sortAtoZ: true)) } } } } Unfortunately, there are two issues with this approach: I am having to fetch multiple items when I only ever want one. Sometimes when running on a new device it will create a second UserSettings while it is waiting for the original one to sync from CloudKit. AppStorage is not an option here as I am looking to persist for the user across devices and use CloudKit syncing.
3
0
315
2w
Any way to remove the persistent "Allow Paste" pop up after user has given permission?
My app makes constant use of copy paste, allowing the user to past links into the app as a core function. Unfortunately users are forced to press the "Allow Paste" button every single time they copy paste, which in my app is constantly. Also the default option is "Deny" even after the user has previously given permission. Is there any way to eliminate the pop up after the user has given permission to the app? I would propose that there be a third option for "Always Allow" paste from this app for the user to select which would silence subsequent pop ups. If the goal is to make a seamless experience for users then we need to consider if we are making things too difficult in the name of security?
3
0
86
May ’25