There and back again: Data transfer on Apple Watch

RSS for tag

Discuss the WWDC21 session There and back again: Data transfer on Apple Watch.

View Session

Posts under wwdc21-10003 tag

7 Posts
Sort by:
Post not yet marked as solved
1 Replies
836 Views
I'm currently learning how to use WatchConnectivity to send data from the iPhone companion app to the Watch extension. I watched the talk "Introducing Watch Connectivity" from WWDC 2015 and downloaded the example project provided by Apple which demonstrates the different WC capabilities. For my specific use case I'm particularly interested in updating the application context on the phone and receiving it on the watch. When I launch the demo app on the phone/watch simulator I see a "Update App Context" button in both UIs. My understanding is that pressing this button for instance on the phone will call the session's delegate callback didReceiveApplicationContext on the watch on the next app launch. While this works as expected the other way round, meaning pressing the button on the watch first and receiving the application context on the phone on app launch, I can't get it to work with the context being sent from the phone to the watch. The breakpoint in didReceiveApplicationContext is never hit. I also noticed that when I set a breakpoint in activationDidCompleteWith on the watch the session property paired and watchAppInstalled are set to false: However both of these properties are true on the phone: I did not touch any of the code in the demo app, just set breakpoints to understand what's going on. My question is: Is it possible to update the application context in both directions?
Posted
by
Post not yet marked as solved
0 Replies
295 Views
Is there a way to start a meditation session on iOS that brings watchOS app to the foreground? For example, some workout apps (built-in Workouts or 3rd party — FutureFit) are doing that, but looking through documentation I cannot find a way to do so. In Coordinate with the Companion App section (https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/running_workout_sessions) they hint that users should open the app themselves: If the user starts a workout in the iOS companion, and then opens your watchOS app
Posted
by
Post not yet marked as solved
0 Replies
227 Views
I watched the video listed at https://developer.apple.com/videos/play/wwdc2021/10003/ and found it very valuable. But what I don't know is: What IDE or toolset/libraries are required to build for watch? Once built, how do you get it on your watch?
Posted
by
Post not yet marked as solved
0 Replies
199 Views
I currently am working on an application that will collect sensor data on an Apple watch and then transfer it to an iPhone and then send it to my database. The biggest struggle I'm currently having is that I cannot get the watch to continue to collect data when the watch face is not pointed at the user. I have tried turning settings on within the watch and done some research on background activity within my app, but nothing is working. All I really need to be able to do is have the watch be always on/active and not "fall asleep" whenever the wrist is turned. This will allow me to continuously collect data and send it, even when the user is moving their hand around
Posted
by
Post not yet marked as solved
1 Replies
105 Views
Hello! I am getting error Fatal error: Index out of range when trying to plot the heart rate for the past month with dates as its xAxis. Below is the code im using. Im using the Dateformatter to convert date to string and then NSString to get an Int. This is what im guessing is causing the error The goal is to have the xaxis be the date / time of the heart rate interval and the yaxis be the Beats per minute.  let startDate = Calendar.current.date(byAdding: .month, value: -1, to: Date())  let query = HKSampleQuery(sampleType: sampleType, predicate: predicate, limit: Int(HKObjectQueryNoLimit), sortDescriptors: [sortDescriptor]) { query, result, error in               guard let samples = result as? [HKQuantitySample] else {         return       }               for sample in samples {         let unit = HKUnit(from: "count/min")         let HR = sample.quantity.doubleValue(for: unit)                     let dateFormatter = DateFormatter()       let startDate = dateFormatter.string(from: sample.startDate)       let dateInt = (startDate as NSString).integerValue                 var yValues = [ChartDataEntry]()                   yValues.append(ChartDataEntry(x: Double(dateInt), y: HR))                 let set1 = LineChartDataSet(entries: yValues, label: "Test")                 let data = LineChartData(dataSet: set1)                 self.lineChartView.data = data                 }     }           store.execute(query)
Posted
by