watchkit

WKURLSessionRefreshBackgroundTask isn't called when attempting to do background refreshes in watchOS

你。 提交于 2019-11-29 14:39:39
问题 I'm working on a complication to get scheduled data from a web service. Every 20-30 minutes (or manually), I am scheduling a WKRefreshBackgroundTask to do this. As suggested by Apple, I want the OS to handle the fetching of this data via a background NSURLSession . This is the function I use to download the data I need: func scheduleURLSession() { print("\nScheduling URL Session...") let backgroundSessionConfig:URLSessionConfiguration = URLSessionConfiguration.background(withIdentifier:

Call external function using WatchKit force touch MenuItem

▼魔方 西西 提交于 2019-11-29 14:18:21
I need to implement a WatchKit force-touch MenuItem to call a saveWorkout() method that is located in a separate class that does not subclass WKInterfaceController . I realize that every class needs at least one designated initializer. I am guessing this is the key? Btw, my " saveSession() reached " print statement logs to the console when using the sim but not when I use a device. All other print statements log to the console even when using the device. A bit odd. My attempts at initialization throw various errors such as: 1.fatal error: use of unimplemented initializer 'init()' for class

Is there a way to access the haptic feedback via WatchKit?

一个人想着一个人 提交于 2019-11-29 13:59:48
I plan to create an Apple Watch app. Is there a way to access the haptic feedback via WatchKit? No there isn't. The following is from this post https://devforums.apple.com/thread/254540?tstart=15 . There is no access to these hardware features at this time, though there is presentation of a text input controller via WKInterfaceController, which will involve the microphone. Past that, I have no information concerning forthcoming releases. hgwhittle Yes. As of watchOS 2.0, you can give haptic feedback with the play() method method like this: WKInterfaceDevice.currentDevice().play(.success) For

How to run a WatchKit App

こ雲淡風輕ζ 提交于 2019-11-29 13:51:26
I can't run a watchkit app from a new project. If I run Apple's sample project it runs fine. If I add watchkit to my existing project by adding a target for watchkit. Then run it I get a black screen with the time even though in my storyboard I have an interface controller that is set to main that has a blue background. This line of code gets called. - (void)willActivate { // This method is called when watch view controller is about to be visible to user [self.listTable setNumberOfRows:5 withRowType:@"List"]; NSLog(@"%@ will activate", self); } My main app(iPhone app) for iPhone doesn't get

Playing sound in Apple Watchkit

ぐ巨炮叔叔 提交于 2019-11-29 13:47:13
I'm trying to play a sound through the watchkit extension using WKAudioFilePlayer however no sound gets played. I'm using the haptic feedback code as a sort of debug to be sure it executes it (which it does). As a side note, mute is not on and the filename is correct. NSURL *falcon = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"falcon" ofType:@"mp3"]]; WKAudioFileAsset *asset = [WKAudioFileAsset assetWithURL:falcon]; WKAudioFilePlayerItem *sound = [WKAudioFilePlayerItem playerItemWithAsset:asset]; audioPlayer = [WKAudioFilePlayer playerWithPlayerItem:sound]; [audioPlayer

How to programmatically open Apple Watch companion app from iOS app

一世执手 提交于 2019-11-29 12:07:45
I would like to give a hint to the user, that my iOS app supports the Apple Watch. So I would like to link/open the Apple Watch companion app from within my iOS app, very much similar to opening the Settings App using ( [[UIApplication sharedApplication] openURL: [NSURL URLWithString:UIApplicationOpenSettingsURLString]]; ) This shall enable the user to directly navigate to the Watch companion app to setup my app for the watch. I could not find any URL which would open the companion app in general or specific to a section of the companion app. If direct linking is not supported, I am also

Gesture recognition in Apple Watch (WatchKit)

扶醉桌前 提交于 2019-11-29 11:00:35
I'm looking for how to detect gestures in an Apple Watch app, via the WatchKit SDK. In iOS we can use some code like this: - (void)viewDidLoad { ... UISwipeGestureRecognizer *swipeRightBlack = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(slideToRightWithGestureRecognizer:)]; swipeRightBlack.direction = UISwipeGestureRecognizerDirectionRight; [self.viewBlack addGestureRecognizer:swipeRightBlack]; } ...but this doesn't work in the Apple Watch simulator. Is there a way to override the default gesture actions using WatchKit, or just recognize them when the OS receives

Apple Watch: dynamic Long Look not shown, when push opened from Notification Center

懵懂的女人 提交于 2019-11-29 10:26:17
I implemented a custom dynamic Long Look for push notifications on the Apple Watch. This dynamic long look is shown correctly, when I immediately raise my arm after receiving a push notification. However, if I respond later, and tap on the push notification from within Notification Center on the Watch, only the static long look is shown. Is this normal behavior or am I doing something wrong? How are your dynamic long looks behaving? For clarity here are the steps to reproduce . This will bring up the dynamic long look: I receive a push notification on the Watch I immediately raise my arm to

How can I open the parent app on iPhone from my WatchKit app?

◇◆丶佛笑我妖孽 提交于 2019-11-29 09:39:18
问题 I'm trying to open the parent application of my Apple Watch app. In Xcode Beta 2 we could use this code: WKInterFaceController.openParentApplication However, in Xcode beta 3 I couldn't found that code any longer. Now I don't know how to open the parent application from the watch app. Please help. 回答1: The Objective-C method is: + (BOOL)openParentApplication:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *replyInfo, NSError *error))reply The Swift method is: class func

Can I create a WatchKit app without a storyboard (entirely in code)?

蹲街弑〆低调 提交于 2019-11-29 09:15:21
My team is currently working on an iOS application in which we don't use storyboards at all. We create the UI in code instead. So for consistency's sake it would be great if we could create a Watch App target entirely in code. However, both the "Getting started with WatchKit" video and WatchKit Framework Reference mention that you need a storyboard for the Watch App target. Furthermore, in WKInterfaceObject.h the init method is marked as unavailable: - (instancetype)init NS_UNAVAILABLE; So is it really impossible to create a Watch App without using storyboards? If so, what are the reasons