watch-os-3

Local Notification in WatchOS 3

时间秒杀一切 提交于 2019-12-09 18:01:15
问题 I'm using the WatchOS 3 beta and trying to initiate a local notification on the watch. The interface is just one button which calls the "buttonPushed" method in the code below. The app runs fine but I never get a notification. The app structure is the default from Xcode 8 for a WatchKit app. This code is in the InterfaceController.swift file of the WatchKit extension Am I missing something totally obvious? @IBAction func buttonPushed() { sendMyNotification() } func sendMyNotification(){ if

Updating complication with Swift 3 and background task

泪湿孤枕 提交于 2019-12-09 16:39:04
问题 For watchOS 3, Apple suggests updating the complication with WKRefreshBackgroundTask instead of using getNextRequestedUpdateDate . How can I determine the time between two updates using the new approach? I would only hack my data requesting (from an url) into getCurrentTimelineEntry and would update the complication, but I think that's not really what Apple would recommend. A short code example would be a big help. 回答1: I generally covered this in a different answer, but I'll address your

WCErrorCodeDeliveryFailed: Payload could not be delivered

戏子无情 提交于 2019-12-08 14:56:06
问题 I'm working on an app that share data between iPhone and Apple Watch, using WCSession method sendMessage:replyHandler:errorHandler: After implementing that method I get the error like: WCSession _onqueue_notifyOfMessageError:withErrorHandler: errorHandler: YES with WCErrorCodeDeliveryFailed. Error = Payload could not be delivered. import Foundation import WatchKit import WatchConnectivity class ResultInterfaceController: WKInterfaceController, WCSessionDelegate { override func awake

Programmatically notification on apple watch. (WatchOS 3)

冷暖自知 提交于 2019-12-08 12:07:19
问题 How I can programmatically make the notification appear only on the apple watch and only when the event occurs. I searched for a long time on the Internet and in the documentation but did not find the answer 回答1: There is no way for you to decide whether the notification appears on the Watch or on the Phone, the system handles this automatically and you cannot change this behaviour. The notification only appears on the Watch if all of the below requirements are met: The connected iPhone's

When WKExtension.scheduleBackgroundRefresh is supposed to call scheduledCompletion handler?

邮差的信 提交于 2019-12-07 21:17:08
问题 I'm trying to schedule background task with such line: WKExtension.shared().scheduleBackgroundRefresh(withPreferredDate: Date(timeIntervalSinceNow: TimeInterval(5) * 60), userInfo: nil, scheduledCompletion: self.scheduledCompletion) where func scheduledCompletion(error: Error?) { if error == nil { print("successfully scheduled application background refresh") } else { print("error scheduling background refresh, error: \(error)") } } According to documentation: scheduledCompletion A block that

TouchEvents in watchOS 3 SpriteKit?

北战南征 提交于 2019-12-05 16:03:08
When using SpriteKit in watchOS 3, how do you handle the touch events? I am porting the SpriteKit games from iOS and the codes below won't work. Or you have to control the WKInterfaceController somehow? override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {} override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {} override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {} override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {} After a lot of frustration with the same issue, I wound up using gesture recognizers,

“Message reply took too long.” - Watch Connectivity Issues with Watch OS 3

我的未来我决定 提交于 2019-12-04 08:13:31
问题 In my project, I use Watch Connectivity to send messages to and from the Watch and iPhone. I can send a message to the phone and receive an array of strings when launching the app, however when using actions I get the following error; Error Domain=WCErrorDomain Code=7012 "Message reply took too long." Here's how things are set up; First, the watch sends a message to the phone and then the phone sends an array of strings to display in a WKInterfaceTable . This sometimes works when loading the

Updating complication with Swift 3 and background task

别等时光非礼了梦想. 提交于 2019-12-04 03:56:06
For watchOS 3, Apple suggests updating the complication with WKRefreshBackgroundTask instead of using getNextRequestedUpdateDate . How can I determine the time between two updates using the new approach? I would only hack my data requesting (from an url) into getCurrentTimelineEntry and would update the complication, but I think that's not really what Apple would recommend. A short code example would be a big help. I generally covered this in a different answer , but I'll address your specific question here. You're right that you shouldn't hack the complication controller to do any

Handling push notifications while watchOS app is in the foreground?

天涯浪子 提交于 2019-12-03 20:47:27
I am building iOS + watchOS apps that need to notify users with updated information across all of the possible combinations of iOS and watch app states: when both the iOS and watchOS are running in the foreground, when they're both running in the background, and when one or the other is in the background. I am successfully handling push notifications for three of these four situations. Where I'm stuck is when the watch app is open in the foreground but the iOS app is in the background- I can't find any method for the watch Notification Controller, its ExtensionDelegate, or for the iOS

“Message reply took too long.” - Watch Connectivity Issues with Watch OS 3

做~自己de王妃 提交于 2019-12-02 21:44:19
In my project, I use Watch Connectivity to send messages to and from the Watch and iPhone. I can send a message to the phone and receive an array of strings when launching the app, however when using actions I get the following error; Error Domain=WCErrorDomain Code=7012 "Message reply took too long." Here's how things are set up; First, the watch sends a message to the phone and then the phone sends an array of strings to display in a WKInterfaceTable . This sometimes works when loading the app. ( I fetch all NSManagedObjects called Items and use their title string properties to store in an