WatchKit

RSS for tag

Build apps that leverage watchOS features like background tasks, extended runtime sessions, and access to the Digital Crown using WatchKit.

Posts under WatchKit tag

138 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Is it possible to provide an interface for real-time sleep status monitoring
Apple Watch automatically tracks sleep data and syncs it to the iPhone, making it available through HealthKit for historical analysis. However, there is no way to retrieve real-time data on whether a user has entered sleep, or whether they are in a specific sleep stage at any given moment. Is it possible to provide an interface for real-time sleep status monitoring
1
0
27
1h
How to make watchos keep the screen on continuously
We developed a camera remote control app for Apple Watch, but during the development process, we found that Apple Watch is prone to sleep on its own without screen interaction (usually automatically sleeping between 5s and 15s when there is no interaction, but our Apple Watch app actually receives the camera preview video frame data we transmit all the time, and there is no data interaction), and then triggers the sessionReachableDidChange function, and the session.isRechable is false. We hope that the camera remote control app for our Apple Watch can remain on when in the foreground, making it convenient to control our camera app on our phone. We found that DJI's Apple Watch app does not automatically sleep and does not sleep for more than 2 minutes. We have tried many methods, such as heartbeat packets, and I have added WKSupportsAlwaysOnDsplay to the Apple Watch info.plist file, but have not found an effective solution. I hope you can provide assistance, thank you.
0
0
58
1d
how to make sound appear with haptic feedback on apple watch
I've made the code in xcode for apple watch with 2 swift view (contentView.swift and interfaceController.swift).The swift for sound and haptic feedback is in InterfaceController.swift. But the the sound does not appear with haptic feedback in apple watch after complete the xcode. the app is done but no sound appear with haptic feedback when rotate apple watch digital crown. when crown rotated but sound appear code import WatchKit import AVFoundation import WatchKit class InterfaceController: WKInterfaceController { // ... your UI elements func playSelectionHapticAndSound() { // Play a haptic feedback pattern WKInterfaceDevice.current().play(.success) // Load and play a selection sound effect guard let soundURL = Bundle.main.url(forResource: "spin", withExtension: "wav") else { return } do { let player = try AVAudioPlayer(contentsOf: soundURL) player.play() } catch { print("Error playing sound: \(error)") } } }
1
0
152
2d
There is a problem installing the iwatch app. It has been installing
We have recently developed the iwatch app. We will package the APP + iwatch app and publish it in testfight for test download. However, we often find that after the mobile app is downloaded, the iwatch app is also on the iwatch System application inside display. Click install is always in the installation. It has not been installed. Especially when the phone we tested is paired with several watches. Or delete the mobile APP and download it again to recover. But some situations still cannot be recovered. May I ask why it is always installed? We have confirmed that there is no problem with the network, and the pairing connection between the watch and the mobile phone is normal. This problem has caused us a lot of trouble. I wonder if this will happen in the app store. Please give the official reply
0
0
148
3d
HealthKit: Seeking Guidance on Continuous, Near Real-Time Heart Rate Data Conitnously in IOS Application
Dear Apple Developer Support, I am writing to request assistance with an ongoing issue I'm encountering while developing an iOS application that utilizes HealthKit to fetch heart rate data. My goal is to display near real-time heart rate updates continuously same as displaying in the Apple Watch , I want to show in the iPhone Mobile Application for fitness related. I have implemented the following approaches: HKSampleQuery with a Timer: I've set up a timer to periodically fetch the latest heart rate data. Despite these efforts, I'm consistently facing the following problems: Delayed Updates: The heart rate data displayed in the app often doesn't reflect the current heart rate being measured by the Apple Watch. There seems to be a significant synchronization delay. Inconsistent Background Updates: Background updates, even with background app refresh enabled, are not reliable. The app often only updates when brought to the foreground or after being killed and relaunched. Entitlements: The com.apple.developer.healthkit.background-delivery entitlement error is missing. I have thoroughly reviewed Apple's HealthKit documentation, implemented best practices for HealthKit integration, and verified that all necessary permissions are properly configured. I understand that HealthKit may not be designed for true real-time data, but the current level of delay and inconsistency is making it difficult to provide a useful user experience. Could you please provide guidance on whether achieving near real-time heart rate updates continuously in an iOS app using HealthKit is possible? If so, what are the recommended strategies and best practices to overcome these limitations? I have also tested the application on physical devices with Apple Watch, enabled background app refresh, granted permissions, and referred to HealthKit documentation. I would appreciate any insights or suggestions you can offer to help resolve this issue. Thank you for your time and assistance. Sincerely, Venu Madhav
1
0
140
1d
Unincluded dependencies failing to build for watchOS companion app.
When trying to use the watchOS preview the simulator fails to load and throws about 15 errors. Clearly the simulator is trying to load all of the iOS packages to the watchOS simulator. However, these packages clearly aren't included in the watchOS app. Furthermore, both apps build successfully to the main simulators, just not the previews. Having a list of errors that simply should not be there is a pretty big annoyance when something is going wrong. How do I fix this?
0
0
137
2w
Deeplink between two standalone watchos App
I have two standalone app written for watchos (standalone). One to authenticate and one for connectivity to real-world devices. The connectivity app uses the authentication app before every action, Im testing this with two xcode projects I have created and tried different things ended up with this error. authapp://authenticate?callback=linkingapp://callback -[SPApplicationDelegate extensionConnection:openSystemURL:]:2418: URL with scheme "authapp" not supported how to get the url scheme working? Tested this in simulator and real device. info.plist and AppDelegate files are placed in both apps.
1
0
192
2w
Issue with Long Press and Drag Gesture Not Ending When Another Finger Swipes on watchOS
I am developing a watchOS app with a tab view, and inside one of the tabs, I have a 2x2 collection view layout. Each collection item contains a view that handles: Tap Gesture (.onTapGesture) → Executes an action immediately. Long Press Gesture (LongPressGesture) → Triggers an update when long press starts and again when it ends. Drag Gesture (DragGesture) → Updates the position while dragging and resets values when the gesture ends. Issue: Most of the time, the gestures work correctly, but if another finger swipes on the screen while a long press is active, sometimes the onEnded event does not trigger, leaving the button in an active state. Observations: The onTapGesture executes normally without issues. The LongPressGesture starts as expected, but if another finger interacts with the screen, the onEnded of the drag gesture does not always trigger. This results in the button remaining visually or functionally "pressed" until another interaction occurs. Has anyone encountered similar behavior in watchOS? How can I ensure that long press and drag gestures always complete even when another finger swipes on the screen? Thanks in advance!
1
0
305
2w
Immediate crash of Apple Watch simulator when typing a key
I get a crash in Apple Watch simulator (Series 9 45mm 18.0) as soon as the app launch if I type anything on external keyboard (just hitting command key for instance to capture a screenshot). Same crash on series 7 (45mm, OS 18.1) But app works normally when I use mouse to interact with the app on simulator. App does not crash on real device (Watch 4 OS 10.4.1). Nor does it crash on Series 6 simulator (44 mm OS 17.4). Here are the log I could collect (apparently, they contain sensitive language !!! so I attach as a file.: Attached logs
1
0
171
3w
Watch-Phone communication when Phone app is in background
There doesn't seem to be a background mode that will allow an iPhone app to run in the background in order to communicate with its watch app, which is running in the foreground on the watch. Have I missed something? Related but not quite the same: say the iPhone app can run in the background to get location updates. But it only wants to do so when the watch app is running. Is there a way that the watch app can wake, or even start, the iPhone app, and for the iPhone app to then enable location updates? (I have previously implemented Bluetooth background modes - I think I could achieve both of the above if I had the watch and the iPhone communicate using my own BTLE protocol, rather than using Watch Connectivity. Is this true?)
6
0
387
3w
Swift 6 concurrency. Apple Watch App target and -disable-dynamic-actor-isolation.
I've got a watch app, still with storyboard, WKInterfaceController and WatchConnectivity. After updating it for swift 6 concurrency I thought I'd keep it for a little while without swift 6 concurrency dynamic runtime check. So I added -disable-dynamic-actor-isolation in OTHER_SWIFT_FLAGS, but it doesn't seem to have an effect for the Apple Watch target. Without manually marking callbacks where needed with @Sendable in dynamic checks seem to be in place. swiftc invocation is as (includes -disable-dynamic-actor-isolation): swiftc -module-name GeoCameraWatchApp -Onone -enforce-exclusivity\=checked ... GeoCameraWatchApp.SwiftFileList -DDEBUG -enable-bridging-pch -disable-dynamic-actor-isolation -D DEBUG -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS11.2.sdk -target arm64_32-apple-watchos7.0 -g -module-cache-path /Users/stand/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/stand/Library/Developer/Xcode/DerivedData/speedo-almhjmryctkitceaufvkvhkkfvdw/Index.noindex/DataStore -enable-experimental-feature OpaqueTypeErasure -Xcc -D_LIBCPP_HARDENING_MODE\=_LIBCPP_HARDENING_MODE_DEBUG -swift-version 6 ... -disable-dynamic-actor-isolation flag seems to be working for the iOS targets, I believe. The flag is described here Am I missing something? Should the flag work for both iOS and Apple Watch targets?
2
0
287
3w
Configuring WebSocket API for watchOS App
Hi all, I’m developing a watchOS app that uses a WebSocket API to process voice audio. However, I keep encountering this error when trying to establish the connection: nw_endpoint_flow_failed_with_error [C1 <server URL>:443 failed parent-flow (unsatisfied (Path was denied by NECP policy), interface: ipsec2, ipv4, ipv6, proxy)] already failing, returning I’ve read Technical Note TN3135, which outlines an exception for audio streaming apps. My app is an audio streaming app, and I’ve already added background audio mode to the app’s capabilities. However, I’m not sure what else is required to meet the exception described in TN3135. Questions How do I meet the exception outlined in TN3135 for WebSocket audio streaming on watchOS? Does NECP enforce additional restrictions even with background audio enabled, and how can I address this? Any guidance or examples of implementing WebSocket audio streaming on watchOS would be greatly appreciated. Thanks!
2
0
358
3w
Why is SKPhysicsBody not picking up alpha?! SpriteKit for a WatchOS game.
So I'm trying to use SpriteKit to make the background of my game. The walls have alpha 1.0, and the safe area alpha 0 and fully transparent. (e.g. a big black square with a smaller transparent square in the middle of it). Yet sprite kit always assume the entire image is either fully opaque or fully transparent. That defies its purpose isn't it? Is there a way to make this work?
2
0
302
Jan ’25
Sounds (beeps) & haptics not working anymore when in 'wrist down' mode (always on display)
Our watch app, Regatta Timer, is a specialised countdown timer for sailing competitions. It is crucial that the beeps & haptics continue when 'wrist down' on alway on displays. We tried to enable this by adding 'background mode' but that only works in the Xcode Apple Watch simulator, not on an actual device with always on display. Any idea how we can get this working also on the Apple Watch device? In ContentView.swift we currently added this code: WKInterfaceDevice.current().play(sound) } but that doesnt work - regardless of adding , phase == .active` or not. STEPS TO REPRODUCE Install on an ACTUAL DEVICE with always on display start the countdown timer: beeps & sounds are OK (each minute,...) do 'wrist down': the countdown timer continues on the dimmed display, but the sounds & haptics stop working until you raise your wrist to wake up the display.
1
0
419
Jan ’25
Should WCSession.isPaired be true before checking WCSession.isWatchAppInstalled ?
I have a depended watch app bundled with my iOS app. // ... <key>WKRunsIndependentlyOfCompanionApp</key> <false/> // ... My code: guard WCSession.isSupported() else { return } let session = WCSession.default session.delegate = self session.activate() public func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) { // ... if (session.activationState == .activated) { let log = Log(isPaired: session.isPaired, isWatchAppInstalled: session.isWatchAppInstalled) uploadLogToServer(log) } // ... } and also: guard WCSession.isSupported() else { return } let session = WCSession.default guard session.activationState == .activated, session.isWatchAppInstalled else { return } do { try session.updateApplicationContext(...) } catch { uploadErrorToServer(error) } What I've observed is that when I query the logs in the server's database, I get entities with isPaired = false and isWatchAppInstalled = true. Also, when I query the errors I see deviceNotPaired errors. So my question is, does Should WCSession.isPaired property be true before accessing WCSession.isWatchAppInstalled property ?
1
0
424
Jan ’25