WatchKit

RSS for tag

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

WatchKit Documentation

Posts under WatchKit tag

134 Posts
Sort by:
Post not yet marked as solved
2 Replies
487 Views
I am developing issuer non-UI extension. In function status i have to return remotePassEntriesAvailable (boolean) and to do that i have to activate WCSession from that Extension to get the remoteSecureElementPasses which are already added to the remote wallet (watch). I have implemented WCSessionDelegate inside the non-UI extension but i can not enable the WCSession. I always get: Error: WCSession has not been activated I saw a comment in this post -> WCSession is not available from iOS extensions, only from the main iOS app. To the point... If the WCSession is not available from iOS extensions how can I properly set remoteSecureElementPasses and implement function remotePassEntries if i can't connect to the watch to see which cards are already enrolled?
Posted Last updated
.
Post not yet marked as solved
2 Replies
469 Views
We have an IOS app and its watch extension. The watch extension having complications as well created with clockKit Also we are providing a watch face with our custom complications for the user. Everything working fine watch series 6 and above Now we have an issue reported by a customer in watch series 3 (the watch Os version in 8.8), in which the watch face is not able to add as it showing the error "Watch Face Unavailable" So when we tried to create a another watch face for watch series 3, the complication list on the watch extension as well as the watch app of iPhone are not listing our app name Because of this issue we can't create a custom watch face for the watch series 3 with our complications So why the watch app in iPhone is not listing our watch app name in the list of complications Please update if anyone having similar issues
Posted Last updated
.
Post not yet marked as solved
3 Replies
520 Views
watchOS 10.4 Beta2 (21T5196d) broke its browser component! You can send youtube.com to your Apple Watch via iMessage, and then open it! Everything worked fine in the official version of watchOS 10.3; you couldn't watch videos because the Apple Watch's WebView doesn't have a video component, but you could at least browse web pages normally. However, in watchOS 10.4, WebView is completely broken, and you can't even view the homepage recommendations or try searching for content properly — web pages refresh automatically within seconds and keep crashing repeatedly. Please revert everything back to the state of watchOS 10.3! The minimal demonstration link to reproduce this bug: https://ling-bucket.oss-cn-beijing.aliyuncs.com/apple/minimalVideo.MOV
Posted Last updated
.
Post not yet marked as solved
1 Replies
428 Views
My watch APP needs to keep Bluetooth connected with peripherals whether it is in the foreground or background, but the results of my test show that the connection in the background is very unstable, sometimes you can keep the Bluetooth on for a day, but sometimes it will be disconnected 50 times a day, and every time it is disconnected, I will immediately initiate a reconnection, it is certain that there is no problem with the peripheral Bluetooth, because I have another iOS device that has been stably connected to the peripheral, I want to know what causes this instability, and if there is any solution, if someone can provide relevant advice, I will be very grateful
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.4k Views
I’ve created a single-target watchOS app in Xcode 14, but I can’t seem to get ClockKit complications working. I’ve added a CLKComplicationDataSource class to my watch target, and in the Info pane for my target I have set the CLKComplicationPrincipalClass key to MODULE-NAME.ComplicationController I haven’t yet added Complication placeholder images to my Assets.xcassets, but as far as I am aware, that shouldn’t be a problem while I am still testing. However, when I run it on a watchOS simulator, the complications never show up on the watch complications list when adding a complication. All of the tutorials I can find for ClockKit complications reference older two-target WatchKit apps. Do the newer single target apps no longer support ClockKit? If so, how can I make a two-target WatchKit app with Xcode 14? Unfortunately I cannot use WidgetKit for my complications because I need to support watchOS 7 at least, and WidgetKit only supports watchOS 9+ Thanks for your help
Posted
by AlwardK.
Last updated
.
Post not yet marked as solved
1 Replies
546 Views
I use setTitle() to display a custom text on the top left corner (aligned to the clock) of a controller. But after upgrading to watchOS 10, the title is displayed on the right, under the clock, pushing all the design down. Is there a workaround to make the title behave as it did on older versions?
Posted Last updated
.
Post not yet marked as solved
0 Replies
431 Views
Errors: ''Invalid info.plist key. The key 'NSHealthShareUsageDescription'' ''Invalid info.plist key. The key 'NSHealthUpdateUsageDescription'' The app works fine when I just run it on hardware without deployment, but as soon as I try to distribute it, this shows up. The keys above are both defined and described in my App and extensions lists, so what's wrong?
Posted
by ksinha.
Last updated
.
Post not yet marked as solved
0 Replies
386 Views
I am making an application that plays music and vibrates at regular intervals. When you put your arm down, the following situation occurs. Music stops (volume goes to 0?) Vibration stops How can I make it so that it does not stop even if I put my arm down? Supplementation In the WatchOS settings, "Always on" is enabled. I use AVAudioPlayer for sound playback.
Posted
by t_misei.
Last updated
.
Post not yet marked as solved
1 Replies
588 Views
I am trying to add a watch target in my existing project using XCode 15.1 but I am not able to see any watch simulators for this to run my watch app. I created a small sample project separately where I can see watch simulators reflecting in the run destination. Can somebody please help me to locate which property or setting I need to check which is disabling XCode to show watch simulators? I have downloaded the watch simulator.
Posted
by binga11.
Last updated
.
Post not yet marked as solved
0 Replies
637 Views
When connecting my iphone (14pro with iOS 17.2.1) with a paired apple watch (series 9 with OS 10.3), it is not showing up on the devices/simulators list in xcode 15.1. Beyond unpairing/repairing the watch, restarting either iphone or watch, connecting/disconnecting the iphone from the computer or deleting xcode and re-installing xcode, any other suggestions? Under the WatchApp field it shows "no eligible device connected", however, under the console the Apple Watch does appear. I have tried just about everything and can't get the watch to appear in Xcode. I am running all this on a MacBook Pro with Sonoma. Thanks for any assistance!
Posted
by jarns.
Last updated
.
Post not yet marked as solved
0 Replies
462 Views
Hi folks! We are developing a WatchOS companion app which records Accelerometer data. We call CMSensorRecorder.recordAccelerometer(forDuration: _) and retrieve the data by calling CMSensorRecorder.accelerometerData(from: _, to: _). So far so good. But the issue arises when we have a data for say 2 hours. We get the accelerometer data in the SwiftUI Task or using GCD's background queue. The data we get is in the loop, enumerating the CMSensorDataList. The loop goes on when the app is active. But as soon as the Watch app goes to inactive state, say applicationWillResignActive is called, the loop is suspended. I know this is the default behaviour of the OS. But this makes our data parsing so slow that sometimes it takes an hour or so to get 2 hours data. This is making our app not user friendly. Is there a way we can keep our app alive as soon as the data is being processed? Or is there another way for faster data processing that we can send the raw data to phone using WCSession so that the data gets there as soon as recording stops? Thanks
Posted Last updated
.
Post not yet marked as solved
2 Replies
706 Views
I can't get the simplest Widget to work. I simply want to present the app's icon. It does what it's supposed to do in the simulator but on the actual device it only says "Please adopt containerBackground API" at the place where the Widget would have shown otherwise. I found out that I am supposed to add .containerBackground(Color.clear, for: .widget) for no reason at all to make this work. However, when I do that, I just get a gray circle where the app icon was supposed to show. The png files should be fine because again on the simulator it works so I have no idea what I am doing wrong. If someone can tell me what I'm doing wrong or if someone can share their Widget class that would be awesome - I literally only want to show my app's icon on the Watch face but I already fail at that, no idea why they made WidgetKit impossible to work with. import SwiftUI import WidgetKit struct IconEntry: TimelineEntry { let date = Date() let icon: Image } struct IconProvider: TimelineProvider { func placeholder(in context: Context) -> IconEntry { return IconEntry(icon: getImageForContext(context, color: false)) } func getSnapshot(in context: Context, completion: @escaping (IconEntry) -> ()) { let entry = IconEntry(icon: getImageForContext(context, color: false)) completion(entry) } func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) { let entry = IconEntry(icon: getImageForContext(context, color: false)) let timeline = Timeline(entries: [entry], policy: .never) completion(timeline) } } struct IconWidget: Widget { let kind: String = "IconWidget" var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: IconProvider()) { entry in IconView() .containerBackground(Color.clear, for: .widget) } .supportedFamilies([.accessoryCircular, .accessoryCorner, .accessoryRectangular]) .description(Text("Show the app's icon on a watch face.")) } } struct InlineWidget: Widget { var body: some WidgetConfiguration { StaticConfiguration(kind: "Inline", provider: IconProvider()) { entry in Text("App Title") .containerBackground(Color.clear, for: .widget) } .configurationDisplayName("App Title") .description("Description") .supportedFamilies([.accessoryInline]) } } func getImageForContext(_ context: TimelineProviderContext, color: Bool) -> Image { var fileNameToUse = "iconColor.png" if(!color) { fileNameToUse = "iconAlpha.png" } let displaySize = context.displaySize if(displaySize.width == 0 || displaySize.height == 0) { return Image(uiImage: .init()) } let uiImage = UIImage(imageLiteralResourceName: fileNameToUse).resizeImage(width: displaySize.width, height: displaySize.height) let image = Image(uiImage: uiImage) return image } struct IconView: View { @Environment(\.widgetRenderingMode) var widgetRenderingMode var body: some View { imageFor(widgetRenderingMode) .resizable() .onAppear { print("ICON VIEW \(widgetRenderingMode == .fullColor ? "COLOR" : "ALPHA")") } .containerBackground(Color.clear, for: .widget) } } private func imageFor(_ widgetRenderingMode: WidgetRenderingMode) -> Image { switch widgetRenderingMode { case .fullColor: return Image(uiImage: UIImage(imageLiteralResourceName: "iconColor.png")) default: return Image(uiImage: UIImage(imageLiteralResourceName: "iconAlpha.png")) } } @main struct IconBundle: WidgetBundle { @WidgetBundleBuilder var body: some Widget { IconWidget() InlineWidget() } } extension UIImage { func resizeImage(width: CGFloat, height: CGFloat) -> UIImage { let edgeLength = min(width, height) let newSize = CGSize(width: edgeLength, height: edgeLength) UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0) self.draw(in: CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height)) if let resizedImage = UIGraphicsGetImageFromCurrentImageContext() { UIGraphicsEndImageContext() return resizedImage } else { return UIImage() } } }
Posted
by Watcher03.
Last updated
.
Post not yet marked as solved
0 Replies
401 Views
Hi, I'm trying to build an app for WatchOS and want to add a translucent capsule with a background blur to blur my text behind it. I tried asking ChatGPT, but it couldn't give me a sufficient answer. I would appreciate it if someone could suggest how I could create that background blur. Thanks!
Posted
by David_Akh.
Last updated
.
Post not yet marked as solved
1 Replies
1k Views
I added a Watch app to an existing iOS app using XCode 14.1. (single target template) When using WCSession delegate, so I can message between the apps, I always get isWatchAppInstalled = false. If Icreate the same scenario using XCode 13.x, I have no issues. Has anyone been able to add a watch app to an existing iOS app, create a WCSession object and have isWatchAppInstalled = true? print("Session:activationDidCompleteWith --> IsPaired[(String(describing: session.isPaired))] isWatchAppInstalled[(String(describing: session.isWatchAppInstalled))] isReachable[(String(describing: session.isReachable))]"); displays: Session:activationDidCompleteWith --> IsPaired[true] isWatchAppInstalled[false] isReachable[false]
Posted
by wolfulve.
Last updated
.
Post not yet marked as solved
1 Replies
510 Views
We are working on a WatchKit app that streams heart rate data to a companion iOS app. This works very well with WCSession, however, when the WatchKit app sleeps, the data does not continue to stream. The only way to get the data to stream again is by moving/touching the Apple Watch and waking it up again. We tried implementing a WKExtendedRuntimeSession, but we were unable to send data with this session. Is there a way to have data to continue to stream continuously, even if the watchkit app falls asleep? WatchOS: 8.8.1 iOS: 17.0 XCode: 15.0.1
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.8k Views
I developed an iPhone/Watch app with the single target setting (new method) for Watch app projects, which will be available from Xcode14. This app uses HealthKit to retrieve information such as step count and heart rate from healthcare. The watch app is not independent and requires the iPhone app (companion app). Regarding the permission to access health care, i found some differences from the Old WatchApp Project (application project structure using WatchExtension when Xcode 13.4 or lower is used). This does not occur in the iPhone simulator or watch simulator, but only on the actual device. Both the iPhone app and watch app now display a dialog to allow access to health care In the Old WatchApp Project, if access was granted in either app, the granted access is synchronized. When checking the Health Care access status in the iPhone Settings App, permission settings for both the iPhone app and watch app are displayed independently. Because each permission setting is independent, you can choose to allow access to the iPhone app but not to allow it to the watch app. the Old WatchApp Project, permission settings for the iPhone app and watch app were synchronized, so it was not possible to have different settings for each. These behaviors are not described in the documentation. It would be understandable if the transition from watch "extension" to watch "app" is to split the app into two separate units. However, since there is no official documentation explaining this, i cannot determine whether this is the correct specification or not. Furthermore, since the companion app is required rather than a separate Watch app, having the Health Care permission settings out of sync with the companion app could cause unexpected problems and worsen the user experience. (It would be difficult and cumbersome for the user to know what settings they have made). Is there a solution to synchronize this behavior with the companion app like as the Old WatchApp Project? Do i have to go back to the project configuration (use of watchExtension) before Xcode13? I have prepared a sample project below that can test the above. https://github.com/HayakawaAKIRA/SingleTargetWatchOSApp-HealthKit reference: https://developer.apple.com/videos/play/wwdc2022/10133/ https://developer.apple.com/documentation/watchkit/wkapplication https://developer.apple.com/documentation/healthkit/setting_up_healthkit
Posted Last updated
.
Post not yet marked as solved
1 Replies
596 Views
Apple Watch Ultra 2, watchOS 10.2 I'm trying to recognize a finger double-tap gesture in watchOS 10.2 on an Apple Watch Ultra 2 or Apple Watch 9. Apple indicates watchOS will invoke primary watch button of app, but I don't know how to specify button as primary. I've written two small watchOS 10.2 SwiftUI apps to demonstrate the problem. Does anyone see what I'm missing, or can point me to relevant docs? APP #1 - simple one-button tap app. Touching button works, but double tap finger gesture seems recognized by watchOS as blue finger icon appears on top of watch display, shaking back and forth indicating it doesn't know what to do, but doesn't invoke Say Hello button. import SwiftUI struct ContentView: View { // Controls whether You did it message is shown @State private var showingSuccessMessage = false var body: some View { VStack { Button("Say Hello") { // This closure is the primary action for the button showingSuccessMessage = true // After 3 seconds, hide the success message DispatchQueue.main.asyncAfter(deadline: .now() + 3) { showingSuccessMessage = false } } // Toggle the visibility of the success message if showingSuccessMessage { Text("You Did It") } } .padding() } } #Preview { ContentView() } APP #2 - basically same app with tap gesture recognizer. Single touch of text works, but double tap gesture while seemingly recognized by watchOS as blue finger icon appears on top of watch display, shaking back and forth indicating it doesn't know what to do, also won't invoke a touch of the Say Hello text. import SwiftUI struct ContentView: View { @State private var showingSuccessMessage = false var body: some View { VStack { // The view that responds to the tap gesture Text("Tap to Say Hello") .padding() .background(Capsule().fill(Color.orange)) .foregroundColor(.white) .onTapGesture { // The action to perform on tap showingSuccessMessage = true // After 3 seconds, hide the success message DispatchQueue.main.asyncAfter(deadline: .now() + 3) { showingSuccessMessage = false } } // Toggle the visibility of the success message if showingSuccessMessage { Text("You did it") } } } } #Preview { ContentView() }
Posted Last updated
.