Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

watchOS Complications deep link to a page in the app

I am trying to build an app that supports multiple complication families on watch OS2 like modular large, utilitarian large, circular small etc, each showing various meaningful information from the app. I know complications is little similar to the glances we have since OS1 in terms of user interaction i.e, it opens the app on user clicking on it and no special interaction over there.

In glance I was able to do a deep link to the app based on current glance content but I am looking for a way to do the same with complications.

So my question is when the user clicks on my app's complication will I get any sort of context information saying this complication was clicked etc. I am thinking like if I may get a CLKComplication Object in the context.

enter image description here

Any help is appreciated.

like image 378
Satheesh Avatar asked Aug 05 '15 16:08

Satheesh


People also ask

Why does it say complications on my Apple Watch?

You can add special features—called complications—to some watch faces, so you can instantly check things like stock prices, the weather report, or information from other apps you installed. With the watch face showing, touch and hold the display, then tap Edit.

How do I get rid of complications on Apple Watch face?

Swipe all the way to the left to edit complications, which you can use to check things like the weather, your activity, or information from other apps that you installed. Tap a complication to select it, then turn the Digital Crown to change it. When you're finished, press the Digital Crown to save your changes.

How many complications can you have on Apple Watch?

With this watch face, you can choose up to three complications as well as a digital or analog dial.


2 Answers

In ClockKit/CLKDefines.h you can find the CLKLaunchedTimelineEntryDateKey constant.
But you can't define your own user info to help you determine what to do when your app is launched.

From the CLKComplicationDataSource Protocol Reference:

CLKLaunchedTimelineEntryDateKey

A key indicating the date with which the complication was launched. The value of this key is an NSDate object. When the user taps your complication, ClockKit includes this key in the dictionary passed to the handleUserActivity: method of the extension delegate.

Available in watchOS 2.0 and later.

like image 195
Fabian Kreiser Avatar answered Sep 28 '22 05:09

Fabian Kreiser


Since you can get the tapped timeline entry's date via CLKLaunchedTimelineEntryDateKey, you can get the complication type (family) by making "fixed second" for specific type's timeline entry.

Fixed second should be calculated by NSDateComponents and then convert to NSDate that you can pass to CLKComplicationTimelineEntry.

For example, you can specify modularSmall entry's date end with 10 seconds but modularLarge entry's date end with 20 seconds. So, tapped entry with date 9:41:10 AM should be a modularSmall type, and entry with date 9:41:20 AM should be a modularLarge type.

like image 40
Jonny Avatar answered Sep 28 '22 03:09

Jonny