Post

Replies

Boosts

Views

Activity

Refreshing AppIntentRecommendation or IntentRecommendation
In my watch app the AppIntentRecommendation that is returned by func recommendations() needs to be updated after the app is launched. Problem: The information that I need to return a list of AppIntentRecommendation is not available when the app is first installed, so I return a "dummy" AppIntentRecommendation initially. After the app is launched for the first time and user has signed in, I can update the AppIntentRecommendation in func recommendations() but watchOS does not update the list of widgets presented as complications. func recommendations() -> [AppIntentRecommendation<ConfigurationAppIntent>] { // Create an array with all the preconfigured widgets to show. let defaults = UserDefaults.init(suiteName: "group.myApp")! guard let names = defaults.dictionary(forKey: "names" as? [String:String] else { return [AppIntentRecommendation(intent: .Demo, description: "Demo")] } var recs = [AppIntentRecommendation<ConfigurationAppIntent>]() for (idx, name) in names() { let rec = ConfigurationAppIntent() rec.order = idx rec.carName = name rec.action = nil recs.append(AppIntentRecommendation(intent: rec, description: "name") ) } return recs } }
1
0
809
Aug ’23
iOS 17 AppIntent and requesting confirmation for widgets
I have a home widget with buttons (new in iOS 17). In order to prevent taking action if the user taps on the widget buttons accidentally, I want to ask the user for confirmation. It appeared that requestConfirmation be exactly what I needed, but no confirmation view shows up when I invoke this method in the perform function. I have tried the following: try await requestConfirmation(result: .result(dialog: "Are you sure you want to do this?") { Image(.mdlsWhite) }) and this alternative: let confirmed: Bool = try await $name.requestConfirmation(for: self.name, dialog: IntentDialog(stringLiteral: msg)) Neither option work. I am starting to think that the requestConfirmation is not to be used with Home Widgets. Is there a better way to handle confirmations for buttons included in a Home Widget?
3
1
1.1k
Jun ’23
Swift: creating shared secret using public and private keys using swift
I am trying to convert an ephemeralKey which is a series of bytes to an Elliptic Curve public key and then use it to create a shared key using my private key. I know how to do this in python (code below). But I cannot find a way to do this in Swift. My swift code is also copied below but it is not correct. Do you see the problem with my swift code? My python code: from cryptography.hazmat.primitives.asymmetric import ec devicePublicKey = ec.EllipticCurvePublicKey.from_encoded_point(ec.SECP256R1(), ephemeralKey) sharedKey = privateKey.exchange(ec.ECDH(), devicePublicKey) My swift code: let attributes: [String:Any] = [ kSecAttrKeyClass as String: kSecAttrKeyClassPublic, kSecAttrKeyType as String: kSecAttrKeyTypeECSECPrimeRandom, kSecAttrKeySizeInBits as String: 256, ] let devicePublicKey = SecKeyCreateWithData(ephemeralKey as CFData, attributes as CFDictionary, nil)! let sharedKey = ecdhSecretCalculation(publicKey: devicePublicKey, privateKey: privateKey) func ecdhSecretCalculation(publicKey: SecKey, privateKey: SecKey) -> Data? { var error: Unmanaged<CFError>? let keyPairAttr:[String : Any] = [ kSecAttrKeySizeInBits as String: 256, SecKeyKeyExchangeParameter.requestedSize.rawValue as String: 32, kSecAttrKeyType as String: kSecAttrKeyTypeECSECPrimeRandom, kSecPrivateKeyAttrs as String: [kSecAttrIsPermanent as String: false], kSecPublicKeyAttrs as String:[kSecAttrIsPermanent as String: false] ] let algorithm:SecKeyAlgorithm = .ecdhKeyExchangeStandardX963SHA256 let shared = SecKeyCopyKeyExchangeResult(privateKey, algorithm, publicKey, keyPairAttr as CFDictionary, &error) as Data? return shared }
1
0
1.2k
Jan ’23
CloudKit returns error 500
Starting about a month ago some of my app users began getting the http 500 error when the app attempts to do anything (read or write) to their iCloud Drive. For AppleIDs that are affected, all apps that use iCloud Drive return the same error. "Request failed with http status code 500" Apple had the same problem last year around the same time (Dec 2021). It was never acknowledged This is a similar issue that happened about a year ago: https://www.macrumors.com/2022/01/26/apple-fixed-icloud-syncing-bug/ Can someone please looking this. I have also filed a bug report with Apple: FB11852660 Since Apple never acknowledges these outages, users blame our app
1
3
1.9k
Dec ’22