watchkit

WCSession and Today Widget

自古美人都是妖i 提交于 2019-12-04 15:59:13
问题 I've an app with a today extension and a watch app. From the main app WCSession works fine and data is transferred to the watch and received correctly but when I try to send or receive data through the WCSession in the today widget the property paired and watchAppInstalled of the session are set to false so calling transferUserInfo: does nothing and session:didReceiveUserInfo: is never called. I know I can open the app using openURL and then send the new data but I want to do that without

How to establish a communication channel between Apple Watch Extension/App and iOS App

浪子不回头ぞ 提交于 2019-12-04 12:29:43
问题 I'm exploring the WatchKit SDK. When I have a WatchKit app, is it possible to set values (e.g. Text, settings) from the iPhone app on the WatchKit app? Can I call functions in the WatchKit app extension from the iPhone app? If someone managed to do this, could he/she post an example? Thanks! 回答1: You can use App Group and sharedDefaults to share data between the WatchApp/Extension and the App on the phone. see example: WatchKit SDK not retrieving data from NSUserDefaults Study up on iOS8

Localize watchkit companion app display name

早过忘川 提交于 2019-12-04 12:10:44
I am having some issues localizing app display name on apple watch companion app. Following the guide lines i have localize the CFBundleName as follow: CFBundleDisplayName = "My app"; CFBundleName = "Myapp"; I did it for every different language supported by my app, but in apple watch companion app it is always shown the english CFBundleDisplayName. Any idea on how properly localize apple watch companion app name? thank you very much for helping I believe that is a bug of the iOS9. The reason is clear, There is no apps on AppStore that provides localized companion App Title. 来源: https:/

Change text color of WKInterfaceLabel using NSMutableAttributedString

谁说胖子不能爱 提交于 2019-12-04 11:49:47
I'm trying to change text color in WKInterfaceLabel using setAttributedText property. Here's the code: MyRowController *row = [self.interfaceTable rowControllerAtIndex:idx]; NSString *str_tmp = @"Test"; NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:str_tmp]; [text addAttribute:NSFontAttributeName value:[UIFont fontWithName:FONT_REGULAR size:12.0] range:NSMakeRange(0, str_tmp.length)]; [text addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, str_tmp.length)]; [row.lines setAttributedText:text]; The result: Only the

Inconsistent behavior of openParentApplication in my WatchKit App

孤人 提交于 2019-12-04 11:16:10
问题 I'm developing an Apple Watch application that uses the openParentApplication:reply: method to communicate with its parent app. The parent app communicates with a web service and sends back the data it gets to the watch extension by means of calling the reply method with a NSDictionary containing the data. The app works perfectly when the parent app is open in the foreground or background. But if I open the parent app and then terminate it using the task switcher, the first time the watch

WatchKit CoreLocation issue

核能气质少年 提交于 2019-12-04 10:14:08
I am trying to read current location coordinates in WatchKitExtension ExtensionDelegate. This does though not return any value. The very same code used in WatchKitExtension InterfaceController does return the location. (tried this out of desperation as I could not find an error in the code) I would need to perform this code in ExtensionDelegate as I would like to pass the retrieved location on to a ClockKit Complication. Here the code in ExtensionDelegate: (after self.locationManager.requestLocation() the delegate functions didUpdateLocation / didFailWithError do not get called) import

openParentApplication only works when the app is running in the foreground

[亡魂溺海] 提交于 2019-12-04 09:45:36
I'm trying to request data from the server by using openParentApplication and use it in the watch extension, but I don't get anything back when the main app is not running in the foreground. When the main app is running in the foreground everything works fine. I had this issue before and the reason was that you haven't registered long running background operation and the system kill it. This is how I sorted this, please see comments for explanations, this is all in AppDelegate file and it in swift but you can easily port it to Objective-c: private var backgroundTask: UIBackgroundTaskIdentifier

Why sending message from WatchKit extension to iOS and getting back a reply is so slow?

こ雲淡風輕ζ 提交于 2019-12-04 08:29:28
I am using sendMessage method to send a message from WatchKit extension to an iOS app. It takes about 230 ms on average to receive a reply. The time does not depend on whether the iOS app is on screen or running in the background. 230ms is roughly the time it takes for light to travel the Earth circumference and back. But the phone is sitting 30 cm from my watch when I am testing this. Questions : Why is it so slow? Is it supposed to be so slow? Is there a way to make it faster? An observation: according my previous experiments in watchOS 1 communication was a bit faster, a roundtrip used to

How to automatically set the version and build number of a Watchkit app target

自作多情 提交于 2019-12-04 08:10:41
问题 The version and build number (or version and short version) of a Watchkit app and extension have to be set to the same value as the containing app. I use environment variables to set the apps version in the Info.plist dynamically at build time. That also works fine for the Watchkit extension, but not for the Watchkit app. The environment variables I use have to be provided in the plist for the main app and extension without ${} (for variable ${VERSION} I set VERSION ). if I do the same for

TestFlight doesn’t support apps with Watchkit extension

给你一囗甜甜゛ 提交于 2019-12-04 05:45:31
After uploading the app via adHoc deployment I see this message on the iTunesConnect. "TestFlight doesn’t support apps with Watchkit extension" Does anyone have a idea why this is shown and what is the solution? Looks like Apple TestFlight is not yet ready for WatchKit apps. You can temporarily disable WatchKit extension inclusion by deleting this row from main iOS app General Settings: The only way is via old school Ad Hoc or enterprise signing (and HockeyApp) There is currently no solution, WatchKit apps cannot be distributed over TestFlight yet. I would estimate it will be enabled sometime