Post

Replies

Boosts

Views

Activity

WidgetKit data is redacted
I'm trying to implement WidgetKit on my watchOS 9.1 app. When I'm editing the watch face, I see the widget looking as I would expect it to be. However, when I then go to the Home Screen, the data is redacted. What's causing that to happen? I don't do anything luminance or security related in the widget's view: struct AccessoryRectangularView: View {   let tide: Tide      var body: some View {     HStack {       VStack(alignment: .leading) {         Text("Height: \(tide.heightString())")           .font(.headline)           .widgetAccentable()         Text("As of: \(tide.date, style: .time)")           .font(.caption)       }              tide.image()     }   } }
1
1
1.4k
Jan ’23
Unable to create complication app id
In the WWDC2020 "Keep your complications up to date" session, Mike shows that you have to create an App ID that ends with ".watchkitapp.complication" in order to support PushKit. Any time I try to add ".complication" to the end of my App ID, it gives an error: An App ID with Identifier 'com.x.y.watchkitapp.complication' is not available. Please enter a different string.
1
0
680
Sep ’21
pushRegistry(_:didUpdate:for:) never called
On my watch only app I added capabilities for Push Notifications and Background remote notifications. Then, in the App I created an instance of my provider. I see the initializer being called, but the delegate methods are never called, so I have no device token. What am I missing? import Foundation import PushKit import ClockKit final class PushNotificationProvider: NSObject {   let registry = PKPushRegistry(queue: .main)   override init() {     super.init()     registry.delegate = self     registry.desiredPushTypes = [.complication]   } } extension PushNotificationProvider: PKPushRegistryDelegate {   func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {     let token = pushCredentials.token.reduce("") { $0 + String(format: "%02x", $1) }     print(token)   }   func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) async {     // Called on the main queue based on the PKPushRegistry queue parameter.     let server = CLKComplicationServer.sharedInstance()     server.activeComplications?.forEach {       server.reloadTimeline(for: $0)     }   } }
0
0
772
Sep ’21
What kicks off a watchOS background URL download
I'm trying to understand the background URL download from the "Keep Your Complications Up To Date" video. I'm confused as to what the refresh method does. In his example, all it does is stores a completion handler. If schedule(first:) is what actually schedules/runs the file download, why not just pass/store the completion handler there? Seems like my applicationDidFinishLaunching method would call schedule(first: true)?
0
0
769
Jun ’21
Time travel in Apple Watch complication
Everything I see from googling says that time travel is gone now on the Apple Watch. However, if I create a brand new watchOS project with complications, there's still a getTimelineEntries(for:after:limit:withHandler) method. So if it exists, how do I use it now, since the setting seems to be gone from the watch app, and if it doesn't, why does the default template still include it?
1
0
879
May ’21
performNotificationDefaultAction with SwiftUI
In my watchOS extension, I'm using the WKUserNotificationHostingController. If I override isInteractive and return true, how do I allow for opening the app? Essentially I want to know how to make the app open when tapping on specific elements of the custom View which is displayed. In previous versions I'd just call the performNotificationDefaultAction method on the WKUserNotificationInterfaceController.
0
0
714
Mar ’21
WKSnapshotRefreshBackgroundTask with SwiftUI
When my SwiftUI based watch app responds to an WKSnapshotRefreshBackgroundTask, how do I change the navigation stack? Before using SwiftUI we'd just do this: if let root = WKExtension().shared.rootInterfaceController { 		root.pushController(withName: "Controller1", context: nil) 		root.pushController(withName: "Controller2", context: nil) } And now I'd have the screen I wanted. Not sure how to accomplish that same thing with SwiftUI
0
0
540
Dec ’20
watchOS NavigationLink not hidden when isActive is false
I'm trying to have a navigation link that is triggered programatically. If I use the following code, on iOS, then the second NavigationLink is not put into the UI, as expected. On watchOS, however, there's a visible button with no text. How can I accomplish this on watchOS? var body: some View {   NavigationView {     VStack {       NavigationLink("No login required", destination: UnprotectedView())       NavigationLink(destination: ProtectedView(), isActive: $isActive) {         EmptyView()       }       Button("Login required", action: pushIfAuthenticated)     }     .navigationBarTitle("Choose")   } }
3
0
2.1k
Dec ’20
SwiftUI know when new page from TabView is activated
In my view I've done this: var body: some View {   TabView {     DayView(summary: History.shared.today())     DayView(summary: History.shared.thisWeek())     DayView(summary: History.shared.thisMonth())   }   .tabViewStyle(PageTabViewStyle()) } how do I tell the appropriate DayView when it has become the active page? If it matters for implementation, this is specifically when using WatchOS.
1
0
723
Dec ’20
Custom Actions for push not working on the simulator
When I run my app on my device and send a push notification, the custom UI shows up and the custom actions appear as well. By custom actions I med the UNNotificationAction items. If, however, I run on the simulator, that doesn't work. When I drag my payload onto the simulator the notification shows and on long-press I see the custom UI, but I don't see any of the custom buttons. Is this a known bug?
1
0
600
Nov ’20
Download file from push notification
In my didReceive(_:withContentHandler:) method I'm trying to download a file. I get the URL of the mp4 file I want to download and then do this: bestAttemptContent.body = "I'm here" do {	 	let data = try Data(contentsOf: url) } catch { 	bestAttemptContent.body = error.localizedDescription } The body isn't modified at all when I do a file download like that. If I comment out line 4, the body is updated as expected. I verified that it's not timing out because the serviceExtensionTimeWillExpire method changes the title so I know a timeout happened and that's not the case. In the debugger I verified the URL is exactly what was passed as part of the payload, and I've verified that URL is correct. If I try to step over line 4 in the debugger it just goes into assembly code and never moves on. The file only takes a few seconds to download from my mac. Both the main project and the service extension allow insecure loads from the net. Any thoughts on why it seems to abort and yet not simply move into the catch block as expected?
0
0
395
Oct ’20