Posts

Post not yet marked as solved
0 Replies
57 Views
Can someone tell me why in the sample code below I am getting the error: Converting function value of type '@MainActor (WebServices.User) -> CKRecord' to '(WebServices.User) -> CKRecord' loses global actor 'MainActor' on this line: try await deleteRecord(record: user, createRecord: createUserRecord) I don't understand the error. If I pass in appSettings to WebServices I don't get this error, but if I have appSettings as an @EnvironmentObject I get this error. Thanks. import SwiftUI import CloudKit class WebServices: ObservableObject { @EnvironmentObject var appSetting: AppSettings private var publicDatabase : CKDatabase? struct User: Identifiable, Hashable { var username: String var id: String = UUID().uuidString } func deleteUser(user: User) async throws { try await deleteRecord(record: user, createRecord: createUserRecord) } private func createUserRecord(user:User) -> CKRecord { return CKRecord(recordType: "User", recordID: CKRecord.ID(recordName: "username")) } func deleteRecord<RecordType: Hashable>(record: RecordType, createRecord: @escaping ((RecordType) -> CKRecord)) async throws { let ckRecord = createRecord(record) _ = try await publicDatabase?.deleteRecord(withID: ckRecord.recordID) } }
Posted
by zach.m.
Last updated
.
Post not yet marked as solved
0 Replies
98 Views
I have an app that uses CloudKit and I have a notification sent if I create a “Notification” record with “Username” set to the signed in user.  This works, but a user could have 2 devices, say an iPhone and an iPad, and be signed in to both devices with the same iCloud account, but be using different app accounts. For example: iPhone - signed into iCloud as “User”, signed into app as “UserPersonal” iPad - signed into iCloud as “User”, signed into app as “UserBusiness” The problem is that CloudKit is tied to the iCloud account so in the above example both the iPhone and iPad will get notifications meant for both “UserPersonal” and “UserBusiness”.  In this example I want “UserPersonal” notifications to just go to the iPhone and “UserBusiness” to go to just the iPad. I see that Apple has added the ability to filter notifications with a Notification Service Extension Filtering Entitlement: https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_usernotifications_filtering I already use a notification service extension so I could use this to filter the notifications going to the same iCloud account and check if it is for the user who is signed into my app account.  But, you have to apply to Apple for this entitlement and it says: “This entitlement is intended for certain types of apps — such as messaging apps or location sharing apps — that use notification service extensions to receive push notifications without delivering notifications to the user.” This is not really my use case. Is there any way I can have a CloudKit notification just go to either app user “UserPersonal” or “UserBusiness” even though they are signed into the same iCloud account? Or, should I just try applying for the Notification Service Extension Filtering Entitlement?
Posted
by zach.m.
Last updated
.
Post marked as solved
3 Replies
1.1k Views
Has anybody gotten AWS CodeCommit to work with Xcode 7?
Posted
by zach.m.
Last updated
.
Post not yet marked as solved
2 Replies
7.4k Views
I have a macOS app that has access to all of the users iCloud files. This means that the app can see any file that the user can see using the Files app in iOS. How can I get access to the same files programmatically from within iOS? I know how to get access to the files in the container for that iOS app, but I don’t see how to get access to all the users iCloud files like the Files app. I‘m sure it can be done because there are lots of file manager apps that access all the users iCoud files.
Posted
by zach.m.
Last updated
.
Post not yet marked as solved
2 Replies
535 Views
I believe that sections in a SwiftUI Form used to extend to the left and right edges, but now the sections are in a card like format and don't extend to the edges. Did Form change recently? Is there someway I can force Form to extend to the edges like it used to? PS - I have before and after photos but no matter how hard I tried to add a link to show them it kept telling me I had to remove the links in order to post.
Posted
by zach.m.
Last updated
.
Post not yet marked as solved
0 Replies
233 Views
I have an iOS app and I need to be able to pick a file on my iCloud Drive, modify the file, and save the modified file with a new extension. I've tried lots of things but I still can't write the new file. Here is my latest code:documentPickerViewController = DocumentPickerViewController(documentTypes: ["public.item"], in: .open) func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { let fileURL = urls[0] do { // Read the file _ = fileURL.startAccessingSecurityScopedResource() let fileData = try Data(contentsOf: fileURL, options: .uncached) fileURL.stopAccessingSecurityScopedResource() // write the file let fileCopyURL = fileURL.appendingPathExtension("copy") _ = fileCopyURL.startAccessingSecurityScopedResource() try fileData.write(to: fileCopyURL) fileCopyURL.stopAccessingSecurityScopedResource() } catch { print(error.localizedDescription) } }When I pick a file on my iCloud Drive I get the following error:You don’t have permission to save the file “TestFile.txt.copy” in the folder “Test Files”.How can a save a modifed file?
Posted
by zach.m.
Last updated
.
Post marked as solved
7 Replies
2k Views
I am exited about CryptoKit and I tried to replace CommonCrypto with CryptoKit for a simple hash I was doing but the results are different. Can anyone tell me why I get different output from CommonCrypto and CryptoKit in the following code? func execute() { let password: String = "Apple!Crypt#Test123" print("password: \(password)") let commonCryptoHashPassword = hashPasswordCommonCrypto(password) print("CommonCrypto: \(commonCryptoHashPassword!)") let cryptoKitHashPassword = hashPasswordCryptoKit(password) print("CryptoKit: \(cryptoKitHashPassword!)") } // CommonCrypto func hashPasswordCommonCrypto(_ password: String) -&gt; String? { // Create the password hash var digest = [UInt8](repeating: 1, count: Int(CC_SHA512_DIGEST_LENGTH)) CCHmac(CCHmacAlgorithm(kCCHmacAlgSHA512), password, password.count, password, password.count, &amp;digest) let passwordHashData = Data(bytes: digest) return formatPassword(passwordHashData) } // CrytoKit func hashPasswordCryptoKit(_ password: String) -&gt; String? { // Create the hash let passwordData = Data(password.utf8) let passwordHashDigest = SHA512.hash(data: passwordData) return formatPassword(passwordHashDigest) } //Format password into readable string func formatPassword(_ password: Data) -&gt; String { var passwordString : String = password.map { String(format: "%02hhx", $0) }.joined() // Add a dash after every 8 characters var index = 8 repeat { passwordString.insert("-", at: String.Index(encodedOffset: index)) index = index + 9 } while index &lt; passwordString.count return passwordString } func formatPassword(_ password: SHA512Digest) -&gt; String { var passwordString : String = password.map { String(format: "%02hhx", $0) }.joined() // Add a dash after every 8 characters var index = 8 repeat { passwordString.insert("-", at: String.Index(encodedOffset: index)) index = index + 9 } while index &lt; passwordString.count return passwordString }Here is the output that I get.CommonCrypto:90cc8e53-49ad79dc-a01de5a0-718744e4-a1180758-fb8a9976-970d1dcb-513ecfdf-abdd8aa7-d152bd5c-17e0c924-e3bf9885-102383a2-2f471eb0-add0fd58-7cc21dd9CryptoKit:6650240f-d532b1b4-a40a1b96-25e2e64c-6d90d5d1-29a14243-0673e408-d3d3c6ea-41adf755-baccd663-a2be7c66-f221d75b-de45d5fe-0f920c9e-8f7d4a2f-af532b3b
Posted
by zach.m.
Last updated
.
Post not yet marked as solved
1 Replies
1.3k Views
If I open the Shortcuts App, edit a shortcut, tap on Apps under Content Types, tap on Open App, then then click choose, why can't I find my app on the long list of apps? I implemented shortcuts in my app and they work fine. In the Shortcuts app I can search for my specific app shortcuts and use them. However, if I try to use Open App my app doesn't show up. In looking through the long list of apps that do show up, only some of them have implemented shortcuts, soI can't figure out what makes an app show up, and how to make my app show up.
Posted
by zach.m.
Last updated
.
Post not yet marked as solved
1 Replies
1.6k Views
I have an app that uses CloudKit and notifications. I write information to a AppNotification record that includes information about the notification like if it has been viewed in the app. I have a subscription on the AppNotification record based on the user ID which creates the notification. I also have a UNNotificationServiceExtension that modifies the notification payload.Everything works fine except for when I get a notification when the app is in the background. In the UNNotificationServiceExtension I don't know how to properly set the bestAttemptContent.badge to be the number of unviewed AppNotification records for that users. In addition, CloudKit seems to have a count of unviewed notifications that don't match the count for my AppNotification records, and is much night because I don't ever do anything with it.Here is what I have tried to get the badge count correct:1) Count the unviewed AppNotification records in UNNotificationServiceExtensionIn the UNNotificationServiceExtension I can read the number of unviewed AppNotification records for the user and then set bestAttemptContent.badge. The problem with this is that I get either the correct count or the correct count -1. It seems like this is because the write of the AppNotification is eventually consistent, and it's not always there. I would have thought that if I wrote an AppNotificaiton record that CloudKit would not send a notification until the record was written, but that doesn't appear to be the case.2) Increment the current badgeIn UNNotificationServiceExtension I could just increment the current app badge count by 1. But, since the UNNotificationServiceExtension doesn't run a part of the app I don't see any way to get the current app badge count.3) Use the CloudKit unviewed notification countI've read the documentation multiple times and I don't really understand this. I don't see how to get a count or modify the count from CloudKit that isn't deprecated. I also don't see how to correlate the CloudKit notification with my AppNotification records. This sounds like the correct way to do this so the CloudKit counts matches the true unread count of AppNotification records.Is there a way to set the bestAttemptContent.badge in the UNNotificationServiceExtension so it matches the unviewed AppNotification count? Is there a better way to do this?
Posted
by zach.m.
Last updated
.
Post marked as solved
3 Replies
615 Views
I have an app that has been in the App Store for years. I want the app to use iCloud so I need to move the app data from AWS to iCloud into a public database. I have already written the app to use CloudKit, so I just need to move the data. I wrote a new app to read the data from AWS and write it to iCloud using CloudKit. I had to change the bundle identifier to match my app in order to get the data in the correct iCloud container. The data gets written into Development and I need it to go into the Production. Since I believe I need to have the app live or in TestFlight to write to production, it seems like I'll have to add the code to move the data into my current app, get the app approved by Apple for testing, and then run the app downloaded from TestFlight to move the data, then take that code our before releasing the app. Is there a better way to accomplish moving app data from AWS to iCloud?
Posted
by zach.m.
Last updated
.