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

132 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Complication works on watch, but not visible in watch app on phone
I have an iPhone app, and added watch support, including a simple launcher complication. I can add the complication using the edit UI on the watch, but the complication is not visible using the watch app on the iPhone. When I add my complication on the watch and then open the watch app on the iPhone, the complication slot shows as "Off". What could I be doing wrong?
2
0
270
Jun ’24
HKObserverQuery not working in background
I'm developing a single target watchOS app that obtains HealthKit information. I have the "Background Delivery" option checked under "Signing & Capabilities" for the watch target. The app does HKObserverQueries in the foreground that work as I would expect. But when I click the Digital Crown to return to clock face, the HKObserverQuery activity stops. I'm using Xcode 15.4, on Mac 14.5 and a Apple Watch Series 4 running 10.5.
2
0
245
Jun ’24
How to use CMHighFrequencyHeartRateData to read the Heart rate data from CoreMotion framework
Hello, As per Apple Documentation Link for CoreMotion framework we can read high frequency heart rate using CMHighFrequencyHeartRateData but there is No way to set the type like heartRate and have a updateHandler to provide the heart rate data. But for Accelerometer data, CoreMotion framework can provide startAccelerometerUpdates(to:, withHandler:) and user can set update interval like accelerometerUpdateInterval using CMMotionManager. But There is no solution available for heartRate. If any solution is available to read heartRate using CMHighFrequencyHeartRateData it will be helpful for me. I know we can read the Heart Rate Data using HealthKit framework using HKAnchoredObjectQuery but the heart rate data is not consistent and startDate & endDate for heart rate data is also not consistent. We want heart rate very frequent like every second. Any help can be appreciated. Thanks in advance
1
0
228
Jun ’24
7014 - Payload could not be delivered.
Hi All, can anyone help me to the below issue? i used the WatchConnectivity to send data from iphone to watch app. Now i tried to run them on emulator (watch series 5, and iphone 15 pro) I have an error when i tried to send message data from iphone app (react-native) to watch app: { "code": "EWCERRORDOMAIN7014", "domain": "WCErrorDomain", "message": "Payload could not be delivered.", "nativeStackIOS": [ "0 releasev2 0x0000000101979c90 RCTJSErrorFromCodeMessageAndNSError + 112", "1 releasev2 0x0000000101979bd0 RCTJSErrorFromNSError + 256", "2 releasev2 0x000000010190c2b4 __41-[RCTModuleMethod processMethodSignature]_block_invoke_4.110 + 148", "3 releasev2 0x000000010185003d __35-[RNWatch sendMessage:reply:error:]_block_invoke.116 + 77", "4 WatchConnectivity 0x000000011428b176 __70-[WCSession _onqueue_notifyOfMessageError:messageID:withErrorHandler:]_block_invoke + 206", "5 Foundation 0x0000000119095004 NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK + 7", "6 Foundation 0x0000000119094f02 -[NSBlockOperation main] + 94", "7 Foundation 0x0000000119097ef2 NSOPERATION_IS_INVOKING_MAIN + 17", "8 Foundation 0x00000001190940aa -[NSOperation start] + 730", "9 Foundation 0x0000000119098744 NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION + 17", "10 Foundation 0x0000000119098385 __NSOQSchedule_f + 182", "11 libdispatch.dylib 0x000000011434ca90 _dispatch_call_block_and_release + 12", "12 libdispatch.dylib 0x000000011434dd3a _dispatch_client_callout + 8", "13 libdispatch.dylib 0x000000011435126a _dispatch_continuation_pop + 874", "14 libdispatch.dylib 0x00000001143502b0 _dispatch_async_redirect_invoke + 994", "15 libdispatch.dylib 0x000000011436041e _dispatch_root_queue_drain + 372", "16 libdispatch.dylib 0x0000000114360e88 _dispatch_worker_thread2 + 244", "17 libsystem_pthread.dylib 0x0000000116800c0f _pthread_wqthread + 257", "18 libsystem_pthread.dylib 0x00000001167ffbbf start_wqthread + 15" ], "userInfo": { "NSLocalizedDescription": "Payload could not be delivered." } } Here is the class connector shared data on watch target: class SharedDataConnecter: NSObject, ObservableObject { var session: WCSession init(session: WCSession = .default){ self.session = session super.init() if WCSession.isSupported(){ session.delegate = self session.activate() } } } extension SharedDataConnecter: WCSessionDelegate{ func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) { print("Active State: ", activationState.rawValue) print("Error: ", error) } func session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) { print("AAAA message from app: ", message) } }
0
0
254
Jun ’24
Ultra Action Button showing on screen
When I initiate WKExtendedRuntimeSession with a background mode of "Underwater Depth" I get an orange indicator showing the Action button on the screen that stays showing all the time and then animates when you press the action button. I believe this started with a recent WatchOS update, because it never happened before. Does anyone know how to hide it? Or keep it and be able to detect the Action button presses within my app (if possible)?
1
0
196
4w
Workout session active but "Return to app" option not displayed in menu
I have an iOS app, with a watch counterpart, used to enter scores for a match. The watch app starts a match (and a workout session) when it receives a notification from the mobile app, after the user started a match on their phone. Basically the watch app is just a more convenient way of inputing scores, so the user wouldn't have to reach for and unlock their phone every time - therefore the need for the watch app to always be displayed. The flow follows these steps: the user is prompted for workout session access when first launching the app; after they accept, I start the workout; the delegate method workoutSession(didChangeTo) returns the expected values; the app remains active, even when the user lowers their wrist; when I go to the clock, the app's icon is displayed in a circle at the top (bringing the app back to foreground on tap). The only problem is that the "Return to app" option in the "Return to Clock" settings menu is missing, what do I need to do in order to display it? Here's an example of what it looks like for the Strava app: and how it looks for mine.
0
1
203
2w
Extract metadata from a .watchface
Hello, fellow developers! How would you approach .watchface file to extract it's metadata? I need to know in which version of the app the face was created, to prompt the user to update the app if necessary. Looking at binary I suppose that a .watchface file consists of a PNG previews and JSON metadata and it all packed in one file somehow. Probably archived with gzip.
0
0
118
1w
WatchConnectivity Session becomes unreachable but shouldn't
So for context I am building an app where the Apple Watch establishes a WatchConnectivity session with the parent iPhone app and streams audio data from the watch Mic to the iPhone for processing on Deepgram to perform STT. This works very well, unless I tilt my wrist and the display goes to sleep. What I find strange is that due to the mic being in use on my watch, the app is still showing on the always on display and is still trying to send the audio data to my phone in the background (which is perfect!) but the iPhone does not seem to be responding. So my watch code is: private func sendData(_ data: Data) { let dict: [String: Any] = ["audioData": data] session.sendMessage(dict, replyHandler: nil, errorHandler: { error in print("Failed to send data: \(error.localizedDescription)") }) } and my Xcode logs Failed to send data: WatchConnectivity session on paired device is not reachable. So the watch is still running the process but because session.isReachable is false the audio data is not sent which it should be! Is there any way to keep the connection established and data sharing when the display dims?
0
0
146
1w
Preventing Apple Watch Screen from Turning Off in Wrist Down Position
Hello, I am developing an application for the Apple Watch that requires the screen to remain active even when the wrist is moved into a down position. The core functionality of my app involves providing continuous visual and auditory guidance, and it's critical that the screen stays on without going into power-saving mode while the app is in use. Specifically, I am looking for a way to: 1.Disable the screen's power-saving mode when the wrist is moved down. 2.Ensure the screen remains active as long as the app is in the foreground. I understand that certain power management features are built into watchOS for battery conservation, but I would need this behavior to be overridden only while the application is running (the app would not be in the foreground for extended periods of time). Is there an approved method or best practice within Apple's guidelines to achieve either of these functionalities? Thank you for your assistance.
1
0
139
1w
Prevent Apple Watch Screen from Turning Off in Power Saving Mode During Specific App Use
Hello, I am developing an application for the Apple Watch that requires the screen to remain active even when the wrist is moved into a down position. The core functionality of my app involves providing continuous visual and auditory guidance, and it's critical that the screen stays on without going into power-saving mode while the app is in use. Specifically, I am looking for a way to: 1.Disable the screen's power-saving mode when the wrist is moved down. 2.Ensure the screen remains active as long as the app is in the foreground. I understand that certain power management features are built into watchOS for battery conservation, but I would need this behavior to be overridden only while the application is running (the app would not be in the foreground for extended periods of time). Is there an approved method or best practice within Apple's guidelines to achieve either of these functionalities? Thank you for your assistance.
1
0
112
1w
Xcode 16 Beta 3 Watch App - No Simulator Runtime Version Even though Simulator is installed.
Today I installed Xcode 16 Beta 3. I have the watchOS 11 simulator installed on my Mac. When building my watch app with Xcode Beta 3 I am getting the following error. /Applications/Xcode-16-beta-3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Library/Application Support/MessagesApplicationStub/MessagesApplicationStub.xcassets: No simulator runtime version from [<DVTBuildVersion 21F79>] available to use with iphonesimulator SDK version <DVTBuildVersion 22A5307d> I have no idea what those assets are for but they aren't part of my project. I tried generating a new standalone watch app project using Xcode 16 Beta 3 and I am getting the same error message so this isn't something particular to my original watch project. Any help on how to fix this issue is appreciated.
1
0
180
1w