watchkit

How can I share information between my iOS and Watch apps using WatchConnectivity?

五迷三道 提交于 2019-12-03 13:46:43
问题 [Disclaimer: this question is intended to be a wiki question to answer the frequent questions about sending data between the iOS and watch apps under the watchkit and watch-os tags.] I am developing an Apple Watch app and would like to send data between the iOS app and its WatchKit extension . I have looked at the WatchConnectivity framework, but don't really understand the difference between all of its methods. Which function should I use if I want to be able to send data even when my apps

Are iPhone's apps notifications going to be triggered on the Apple Watch by default, without even creating an actual Watch app?

家住魔仙堡 提交于 2019-12-03 13:34:23
问题 I would like to support my iPhone's app Local Notifications in the Apple Watch from the very first moment the Watch is released, but I don't plan on building a Watch App yet. From what I researched, it seems like iPhone's notifications will be automatically supported on the Watch, without needing any additional development or WatchKit implementation. Apps are not required to do anything to support notifications. The system provides a default notification interface that displays the alert

How to get sensor data from Apple Watch to iPhone?

强颜欢笑 提交于 2019-12-03 13:01:00
Is there a way to get sensor data from Apple Watch? For example, how can I connect and get heart rate from Apple Watch to my app? These are the steps I need do in my app: Define a delegate to receive heart rate information from Apple Watch. Make a request to Apple Watch to send the data periodically I know how it works for other HR monitors over BT. Is the interface similar to that? Or should depend on HealthKit to achieve that? Greencat As per WatchKit FAQ on raywenderlich.com (scroll to "Can you access the heartbeat sensor and other sensors on the watch from your watch app?") it appears as

How to create sections in WKInterfaceTable

☆樱花仙子☆ 提交于 2019-12-03 12:52:24
问题 How can we create sections in table as there is no delegate for it. And is there any other way for creating sections or do we have to use two tables. 回答1: WKInterfaceTable is not so flexible like UITableView, but you can create rows manually, using different row types. And fill content for each cell according to its type. Take a look at the documentation: Apple Watch Programming Guide: Tables WatchKit Framework Reference: WKInterfaceTable For example, let's create a table having two row types

Apple Watch app detect if a apple watch is paired with the phone

做~自己de王妃 提交于 2019-12-03 12:34:25
When the user opens the app on the phone is there a way to detect if the phone is paired/connected to a apple watch? There is no built-in method (at least in the WatchKit SDK) to determine if a Watch has been paired with an iPhone. A common strategy is to write a BOOL to a shared NSUserDefaults (using app groups) so that the iPhone knows that the Watch app has been run at least once. That's the technique I've used in my own app. So on WatchOS 2 that is possible ! You have to do on iPhone side : First : import WatchConnectivity Then : if WCSession.isSupported() { // check if the device support

Apple Watch set background image

假如想象 提交于 2019-12-03 12:34:10
How can I programmatically set my WatchKit App background image? I need to set this in code as it changes depending on variable size and we need to place a label over the image. It is not possible to programatically set the background image on an entire Watch App page in WatchKit... a background image for the whole page can at the current time only be set in Interface Builder it appears. However, you can set a picture as a background behind a label, and make that image fill the screen: Create a group in your WatchKit scene. You are likely to want to set custom size attributes for the view (e.g

Invalid Bundle error from iTC, cannot submit app - because 4 swift dylibs fail to embed

﹥>﹥吖頭↗ 提交于 2019-12-03 12:33:52
My app runs fine on devices & simulators, but when I submit it, I get the Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path error emailed to me about half an hour after the upload completes successfully. Following the advice on this thead here , namely running otool -L , I can see that the app's main executable has all of its @rpath/...dylib files in the Frameworks/ folder as expected, but , the appex's executable is missing some Swift libs. Here's the output from otool -L on the appex: Watch Extension: /System/Library

The UIApplicationDelegate in the iPhone App never called reply

放肆的年华 提交于 2019-12-03 12:26:09
I am trying to launch my iPhone app from watch simulator using the below code : WKInterfaceController subclass [WKInterfaceController openParentApplication:[NSDictionary dictionaryWithObject:@"red" forKey:@"color"] reply:^(NSDictionary *replyInfo, NSError *error) { NSLog(@"replyInfo %@",replyInfo); NSLog(@"Error: %@",error); }]; AppDelegate.m - (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply { NSLog(@"appdelegate handleWatchKitExtensionRequest"); NSLog(@"NSDictionary: %@",userInfo); NSLog(@

Dynamic Notification Interface will only work if the Watch app \\ extension was opened at least once from the watch

主宰稳场 提交于 2019-12-03 11:56:57
Currently there are 3 flavors of notifications in the Apple Watch: Short - You can't customize these at all. Static - You can customize these on the Storyboard. Dynamic - Can customize UI elements with new data not coming on the Notification payload. Here's the problem (The project is using Watch OS 1), if the app was never opened from the Apple Watch the Static notification will be displayed instead of the Dynamic one and the log will show the error Took too long to show custom notification. Falling back to static I've stripped down the notifications code & ViewController to nothing but this:

Watchkit - How to set the element one below other in Group

不想你离开。 提交于 2019-12-03 11:35:00
I am working on the watchkit app and I want to create a table row with an image and two labels where the labels are one below the other, like this: I tried the position options in interface builder, but no luck. The labels are always on the same line: I want the x-coordinate same for both. Please help. At first, drag a Group onto the interfaceController, then change the Layout property of that group to Vertical : Then drag the Labels in that group and set their properties accordingly: If you need other alignments, add another group to the viewController. EDIT To achieve the table view you have