Post

Replies

Boosts

Views

Activity

SKProductRequest delegate failure with undocumented AMSErrorDomain error
When testing In-App Purchase SKProductRequest with WiFi off and no cellular, the failure delegate method gets invoked as one would expect. Unexpectedly, this happens with an undocumented error domain and codes (AMSErrorDomain). Does anyone know where to find public documentation on the AMSErrorDomain? extension Store: SKProductsRequestDelegate {     func request(_ request: SKRequest, didFailWithError error: Error) {         if let storeError = error as? SKError {             os_log("Failed to load products with store kit error: %@", "\(storeError)")         } else {             os_log("Failed to load products with other error: %@", "\(error)")         }     } ... } (lldb) po error Error Domain=AMSErrorDomain Code=203 "Bag Load Failed" UserInfo={NSLocalizedFailureReason=Unable to retrieve p2-product-offers-batch-limit because we failed to load the bag., NSLocalizedDescription=Bag Load Failed, NSUnderlyingError=0x6000004707b0 {Error Domain=AMSErrorDomain Code=206 "Bag Load Failed" UserInfo={NSLocalizedDescription=Bag Load Failed, NSLocalizedFailureReason=Unable to connect to internet.}}} Clearly the underlying localized failure reason makes sense and is user friendly, however the error objects standard localized description 'bag load failed' is far from user friendly and isn't really acceptable to me to put in front of the user. Apple's very own InAppPurchase sample code just pumps the error localizedDescription into a UIAlertController message--but this can be done better! Title: 'Product Request Status', Message: 'Bag Load Failed' How are others handling failures in the SKProductRequest for non-SKError errors?
0
0
855
Sep ’20
App Clips should support CloudKit for read-only access to the public database
I'm building an app based entirely on CloudKit and I'm super excited for technologies like App Clip to make a mini 'menu' version of said app. The main app target allows vendor/site location managers to update their menu in real time and then signed in iCloud users can subscribe to those public record updates. I just discovered in the technology limitations of App Clips that CloudKit is out. It isn't in the list of 'supported capabilities' in the project editor. Additionally, as one would expect, trying to create a CKContainer without the entitlement in the App Clip target crashes with a fatal error due to the lack of that very entitlement. This feels unnecessarily restrictive and excludes developers from supporting App Clips who build their server tech stack on CloudKit. Write capability isn't needed for my concept. Effectively I'd want for each unique venue to be able to continue to manager their menu/venue via CloudKit + Security Roles and allow updating content in the main app--and for users to view/browse with focused location/venue specific menus in the app clip. As recommended, the full app has to be installed for the full experience. I'd rather not attempt to hit the public database via the JS library, or making an API proxy that just invokes CloudKit web tech under the hood. I really think supporting read operations from the public CloudKit database would enable many experiences that are currently restricted due to this limitation. If someone at Apple is watching, I created FB8528010 feature request with a little more details on my new feature concept.
4
0
1.9k
Aug ’20
How long are HKQuantitySamples available on Apple Watch?
In my application I query data to compose a "Calorie Profile" for computing BMR and active calories during a workout.Several users have reported, in addition to having been seen in development, that .height and .bodyMass quantity samples are not found when queried on Apple Watch, but exist when queried on the paired/associated iPhone.How long is data made available on the Apple Watch?More specifically, I have a height sample saved on Oct 31st 2019 that is visible in the Health App, and queryable on my app on iPhone. This same sample quantity is not returned on the watch. I'm executing a simple unbounded sample query.For sanity checking, I just saved a new height sample (today) and refreshed the watch app. Less than 5 seconds later, the data was available. Next test was to delete the new sample, so the previous sample was then Oct 31st again. The query returned nothing again.extension HKHealthStore { public func mostRecentHeight(completion: @escaping ((Result<measurement, Error>) -> ())) { self.execute(HKSampleQuery.lastSample(for: .height, completion: { (height, error) in guard let heightQuantity = height else { completion(.failure(QueryError.nilError)) return } let height: Measurement = Measurement(value: heightQuantity.quantity.doubleValue(for: .meter()), unit: .meters) .converted(to: .feet) // TODO: Convert to preferred unit type completion(.success(height)) })) } } private extension HKSampleQuery { static func lastSample(for type: HKQuantityTypeIdentifier, completion: @escaping (HKQuantitySample?, Error?) -> ()) -> HKSampleQuery { guard let sampleType = HKObjectType.quantityType(forIdentifier: type) else { fatalError("Unknown sample type \(type)") } let sortDescriptor: NSSortDescriptor = NSSortDescriptor(key: HKSampleSortIdentifierStartDate, ascending: false) return HKSampleQuery(sampleType: sampleType, predicate: nil, limit: 1, sortDescriptors: [sortDescriptor], resultsHandler: { (query, samples, error) in completion(samples?.first as? HKQuantitySample, error) }) } }
0
0
472
Jan ’20
New advertisement key CBAdvDataTimestamp?
I discovered tonight in iOS 13 beta 8 that there is a new key and value in the advertisement payload. I didn't notice it before and it very well may have been there prior.The key is visible when printing out the advertisementData dict, and a typecast passes as TimeInterval if let timespan = advertisementData["kCBAdvDataTimestamp"] as? TimeInterval { print("Adv date intv \(timespan)") }I didn't see this documented in the API reference under new or old keys. Is this going to be in production? Android API captures timestamp of adv packet since boot--it would be nice to have something similar on iOS (point of reference can be epoch).These are the values that it was decoding as:Adv date intv 588221792.199425Adv date intv 588221793.25799Adv date intv 588221794.237889Adv date intv 588221795.255606Adv date intv 588221796.249666Adv date intv 588221797.243745They're nothing close to the epoch or seconds since boot. I got this out of the payload on my polar HR7.["kCBAdvDataManufacturerData": <6b000900 0000>, "kCBAdvDataTimestamp": 588222227.821503, "kCBAdvDataServiceUUIDs": <__NSArrayM 0x280657cf0>(Heart Rate), "kCBAdvDataLocalName": Polar H7 --------, "kCBAdvDataIsConnectable": 1, "kCBAdvDataTxPowerLevel": 0]
2
0
3.1k
Aug ’19
CBCentralManager is presenting the PowerAlert on initialization when options are not presented.
iOS 13 Beta 4, iPhone Xs.I'm seeing the power alert show even though the options are not specified. I have created a feedback/radar for this: FB6810811If this is the new behavior to expect for GM, the default init documentation should be updated accordingly. Seems like a bug to me as there is a second initializer to explicitly invoke this behavior.import UIKit import CoreBluetooth class ViewController: UIViewController { let centralManager: CBCentralManager = CBCentralManager(delegate: nil, queue: .main) }
1
0
670
Jul ’19
Bluetooth privacy usage prompt displayed immediately upon initialization of CBManager classes
iOS 13 is requesting Bluetooth permission immediately upon central manager initialization. From the Bluetooth 2019 talk, the presenter illustrated in the didUpdateState method to check the authorization state and appropriately prompt the user (presumably the same way you would with CMPedometer--invoke a instance method). Is this behavior to expected in the GM seed? It is counter intuitive and doesn't conform to the pattern that other frameworks use for their authorization workflow.This permission model seems to be incorrect, most other frameworks have a static method on the corresponding class to get authorization status. For example https://developer.apple.com/documentation/corelocation/cllocationmanager/1423523-authorizationstatus, https://developer.apple.com/documentation/coremotion/cmpedometer/2913743-authorizationstatus. The API signature that has a "notRequested" state, will seemingly never be the case since the prompt happens upon first initialization NOT first usage. CMPedometer initialization does not initiate the privacy prompt, only calling a method to do work does. CLLocationManager has explicit methods to invoke the authorization modal.If we don't have the class func to check authorization, and are dependent on an instance of CBCentralManager to have been initialized with a delegate, we can't design an elegant workflow to prompt the user at the appropriate time.
3
0
3.4k
Jul ’19
iOS Dark Mode UINavigationBar not updating background color
I figured that I'd get the support for Dark Mode out of the box with UINavigationBar since I use the default opaque color scheme.I've noticed that when I switch the dark mode setting to ON either from environment in xcode, or command center with the screen brightness shortcut, my UINavigationController navbar background stays white but the title text color does change to the dark mode title color, white. White text on white background. I verified that the label is still there and still white using the Debug View Heirarchy within xcode.Sometimes, when I rotate then to landscape, the background will update to dark mode color. It isn't consistent. Same goes for the inverse, changing dark to light mode. Dark text on Dark background color.From a user's perspective, after a swipe-kill and relaunch, the color matches the themes in all orientations and navigation bars.I have my nav bars set to opaque from storyboard. Is there something else I'm missing that needs to be done? I didn't see anything in the adopting dark mode video from WWDC 19.Updated Aug 26, 2019I'm still seeing this behavior in dev beta 8. Created a bug report--hopefully this gets fixed. FB7134275Is anyone else affected by this? Basic app layout similar to either Phone or Clock app.UITabBarController (opaque bottom bar) - UINavigationController (opaque top bar) - UIViewController UINavigationController (opaque top bar) - UITableViewControllerThis is really non-functional because the title color is changed, but the bar color is not changing.Update Jan 6, 2020iOS 13.3 no longer seems to have this issue. I'm not sure in which earlier update this was addressed.
8
1
12k
Jul ’19
CloudKit operations using publicDatabase queue unreliable
CloudKit CKOperations do not complete when on cellular. When they do its once in a blue moon.I schedule things with allow cellular, and have verified in settings that iCloud allows cellular access. When I add any operation to the public database it will not do anything until I flip my device to wifi. This isn't acceptable as it is taking advantage of the location queries and is an on the go application.Has anyone come up with a workaround? Other posts suggest that it is a reported buy but has been around for a while so I'm not entirely sure.Edit:I have unit tests setup to do everything not only my application. When I run my unit tests with wifi off, they fail (30 second timeout without callback). After running them a few times with wifi (passing) and then switching they all of a sudden work on cellular (4 for 4 runs).I was able to run the app immediately after the successful cellular unit tests once. Its now back to failure.
6
0
1.5k
Oct ’15