Post

Replies

Boosts

Views

Activity

Reply to Is it possible to measure distance (in metrics) using CoreMotion (iOS)?
Fitness and Navigations apps commonly use what is called the "Kalman Filter" for positional updates over time. In summary, you can use GPS to determine your position in 2D or 3D coordinate space. For the x and y position use case, you then use velocity, and acceleration to account for error in your sampling. CLLocation has a speed value, but it isn't to be used other than for informational. So the idea here is to use CoreLocation + CMDeviceMotion data to get a better location fix. Will it get the accuracy you're looking for? No promises there. For discussion purposes, is your iOS device free body or fixed body? I.e. in someone's hand, or on a robot where the axis won't change. If the latter where the orientation will always be the same respective to the x/y plane, you could look into using linear acceleration data with accumulation.
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’20
Reply to auto workout detection with custom activity classifier
Think about Apple's new hand washing detection, a developer probably wouldn't be able to achieve this given the public API set; as you pointed out we don't get 'always' motion updates. To speculate, their ML model probably uses acceleration, hand position, sound, and other factors as input into their classifier. Is your application health or fitness related? If so, given your legitimate use case for accessing the users Health and Fitness data, you could perform a long running query with background updates for something like Step Count or distanceWalkingRunning updates. https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery Do note, as the documentation states, some of the data is 'throttled' to so many updates over time. Hope this helps.
Topic: App & System Services SubTopic: Core OS Tags:
Sep ’20
Reply to CMAltimeter reports wrong relativeAltitude values while an active HKWorkoutSession is paused on watchOS
I added elevation gain tracking to my fitness app earlier this year in my Hiking update. I haven't seen anything like this in development or heard any reporting from the field. I have a Series 3 with 6.2.8 and have never noticed anything like this. As far as I know, CMAltimeter solely uses a barometric pressure sensor under the hood, well at least until the new watches that use GPS and Wi-Fi for improved data in that always-on scenario. Barometric pressure sensors have a sampling time where they 'accumulate' change, so we are limited by the update frequency of both the hardware and software. I'll probably put something like this in my code to account for this; so I appreciate your share! I'd start by keeping track of my last known presumed good/first CMAltitudeData, then put the following (pseudo-code) guards into my update handler: guard newData.timestamp > lastData.timestamp else { BAD } guard abs(newData.relativeAltitude - lastData.relativeAltitude) < Constants.reasonableAltitudeDelta else { BAD } Unless your app supports cliff jumping or some other crazy activity, assuming the update frequency of the altimeter API is 1hz, maybe it would be appropriate for the user to change say 2 m/s? So in guard 2, compare your elevation change over time to some velocity number. Furthermore, you'd need to understand and handle the cases where your lastData is actually the bad one, or enough time has passed where you just wanna give up start accumulating +/- elevation again. I applied similar filtering (plus more) to my CLLocation data before adding to my workout route. Questions: By chance, do you have any CLLocation data during the 'paused' portion of your workout to correlate it against? Could you share an example print out of your [CMAltitudeData] as well as markers where you paused your workout? Roughly how many seconds after you paused the workout session did you see the elevation return to 'normal' values? Any difference when you are doing a running workout with your watch set to auto-pause, vs you programmatically calling session.pause()? As I mentioned, I have a Series 3, and a new Series 6 on the way. I will do some testing to see if I can reproduce what you're seeing and reply with my results.
Topic: App & System Services SubTopic: Core OS Tags:
Sep ’20
Reply to iPhone is not available. Please reconnect the device.
If you are encountering this via wireless debugging, turn off wifi + bluetooth on both your Mac and iPhone. Not just the toggle no new connections but go to settings and disable. After both are off, turn both radios back on. Something else that sometimes helps is swiping to reveal Control Center and just let it sit there for a few moments. When this happens to me, I will typically plug in and debug with cable. If that doesn't work, reboot both devices.
Oct ’20
Reply to Fix CloudKit container permissions
I've have been experiencing the same CKError (10) which is a permission failure--but not one per their documentation. In other words, it is not a security role thing. One attempt was on a completely new container with no defined roles. https://developer.apple.com/documentation/cloudkit/ckerror/code/permissionfailure "This error typically occurs in the public database in one of these circumstances: You have roles defined for record types. Your app is trying to accept a share that the current user was not invited to." Following some archive documentation, I was adding my container to a second app as described in the section "Share Containers Between Apps" here: https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/CloudKitQuickStart/EnablingiCloudandConfiguringCloudKit/EnablingiCloudandConfiguringCloudKit.html This gave me the same error as described above (10/2007) However, unlike you, creating a new container and using it in ANY of my development/TestFlight apps did not work. Doing so resulted in the same error. My troubleshooting so far was: Uncheck/Recheck the container identifier in signing + capabilities Kill Xcode followed by reboot of iPhone + Mac Remove all mobile device provisioning profiles that Xcode manages Delete all provisioning profiles on the iPhone using Xcode Devices window Create new container and attempt to connect in app Nothing seemed to work. Seems like it is an Apple problem and not me (us)! Glad I found your post before making my own of the same nature. I filed a Feedback Assistant bug yesterday for this exact error code (10/2007). Please file a Feedback Assistant bug too and feel free to reference my number so they can see it is affecting more than one developer. FB8826569
Topic: Code Signing SubTopic: Entitlements Tags:
Oct ’20
Reply to CloudKit Permissions
You want to look into the Security Roles available in CloudKit Dashboard. There are three default flavors of roles: World, Authenticated, and Creator. World: Everyone with app access, no CloudKit sign in required (read only) Authenticated: User of your app signed into iCloud Creator: The user that created the record, i.e. the same userID populated in the "creatorUserRecordID" field aka 'createdBy' if you're familiar with that term from other technologies You can also create your own role which presents itself as a checkbox on the "user" record type in the CloudKit Dashboard. I'm building out an app that will use a 'custom app' distributed to businesses, and then a user facing app on the App Store. These two applications will use the same CloudKit Container and use roles to achieve some read-only sections of the public database, and others that are create/read/write. I have created an "Admin" role very similar to what you are doing above. So for your scenario, change the default permissions on the Authenticated role and remove the create and write permissions (do this for every record type). Next, create the new role, and assign to the users you want to be able to update. If the user set that need write access is large, you could explore using tokens--though I haven't tried this before. Please note, if you create new record types, be sure to remember to uncheck the permissions you want to restrict for authenticated and setup your admin role respectively before you deploy your schema to production!
Oct ’20
Reply to How often do I schedule Widget updates?
Simon, Did you have any success with HKObserverQuery and reloading the timeline? I have a workout app that has a "workout" widget. Presently, I have an observer query listening to .workoutType() and I set the background update frequency to .immediate. On iOS 12.2 RC for my iPhone XS, I keep seeing the observer query getting invoked second after second--even though there is no new workout being saved. Have you experience anything like this where the observer query is getting hammered with updates more than you expect? I'm guessing it is some bug where the HKObserverQuery is getting invoked as if the app was entering foreground, and the widget being on screen is somehow tripping this. I filed a FB on this unexpected behavior in case anyone at Apple sees this and wants more details. FB8887079
Topic: App & System Services SubTopic: General Tags:
Nov ’20
Reply to Reading from CloudKit fails under Catalyst
Just upgraded my Mac to Big Sur and can finally run my catalyst app built on a SwiftUI app. I'm seeing the same thing using Xcode 12.2 RC. I've tried adding the CKQueryOperation directly to the publicDatabase, as well as, adding the op to OperationQueue.main directly after having specified the database as the public one. None of the operation blocks are firing, recordHandler, queryCompletion, or operation completion handler.
Nov ’20
Reply to App Clip: [App name] is not compatiable with this iPhone
We've released a build which contains the app clip. It's working fine under TestFlight, Local Experience, however, when we open it through Smart Banner, the card says [App name] is not compatible with this iPhone. Same here. @marspark was your issue ever resolved? I'm encountering the same false positive. My app update just went live and upon deleting the previously released App Store version from two of my iPhones and triggering the App Clip from my website, I was presented with the same 'not compatible' message. My first thought was that it was something to do with the entitlements, but based on the Apple reply here it seems to be the device capabilities that it is tripping on. For my required device capabilities, my app uses HealthKit. Originally I didn't have any required device capabilities but it turns out to be a compiler error if your app clip's required device capabilities do not match your main targets. I don't use HealthKit in the App Clip (you can't), so there is no entitlement for health access, and subsequently no info.plist usage description string for it either. Installs just fine from test flight, local experience launched, etc. Same as the original poster. Here is the list of capabilities that both my app target, and my clip declare: <key>UIRequiredDeviceCapabilities</key> <array> <string>arm64</string> <string>healthkit</string> <string>bluetooth-le</string> <string>location-services</string> </array> Both of my iPhones support this app because they can download the full one from the store no problem. Collecting sysdiagnose now for FB8910249.
Topic: App & System Services SubTopic: General Tags:
Nov ’20
Reply to Can we access user health record from healthkit and get patient fhir data?
You can't access the "Health Profile" the user sets up in the Health app, but you can access the 'Patient' data contained within the FHIR resources and then look at the name property. This will require knowledge of which FHIR release a resource is as well as how to decode the JSON. To learn more about FHIR resources, checkout the official hl7.org/fhir site. For R4 version, here is Apple's GitHub FHIRModels lib. https://github.com/apple/FHIRModels/blob/main/Sources/ModelsR4/Patient.swift#L51
Mar ’21
Reply to ASP.Net C# Web App and iOS/Healthkit Step Count
Watching some of the historical WWDC videos about HealthKit would be a great start. Some key classes are: HKSampleQuery HKStatisticsCollectionQuery HKAnchoredObjectQuery HKSampleTypeIdentifier.stepCount, etc. Regarding accessing the data without the user interacting with the app, you'd have to look into background delivery on the HKHealthStore class here - https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery Make sure the user knows that you're doing this :)
Topic: App & System Services SubTopic: General Tags:
Mar ’21