0

I'm trying to build a simple complication template for a WatchOS app, but I'm stuck trying to understand when will the ComplicationController class's method getPlaceholderTemplateForComplication() be called.

Apple's documentation says

When your app is first launched, ClockKit calls this method,

but if i run the simulator, it most often won't fire.

Turning the "Show App on Apple Watch" switch off and back on doesn't help.

When will getPlaceholderTemplateForComplication() method be called?

Julius
  • 409
  • 4
  • 19
  • Please [edit] your question to a) mention that the placeholder does not appear while customizing the watch face, and b) add your `getPlaceholderTemplateForComplication` code. –  Jun 30 '16 at 15:35
  • The placeholder template shows in the app after the placeholder method has been called. This is normal behavior and I don't have any trouble with that. The problem is that the method isn't always called, and I need to know how and when it should execute. – Julius Jul 01 '16 at 06:07
  • The system calls the method *once*, then caches the result. It won't keep calling the method, every time you customize the watch face. Instead of asking how or why the system does something, you should describe the symptom you're experiencing. Does the placeholder appear when customizing or not? Also **please show code**. The problem is more likely in your code, than whether or not the system calls your method, since the system is optimized to know when to call it or not. –  Jul 01 '16 at 10:00

1 Answers1

0

The placeholder template is called when you are customizing the watch face and selecting which complication will be shown. The system calls getPlaceholderTemplateForComplication() once, then caches the result. It won't keep calling the method every time you customize the complication.

As you scroll through the complication choices, the static details shown there are the details returned for the placeholder template.

Once your complication is active -- shown on the watch face -- the placeholder template does not get called. Instead the timeline entries come from these complication dataSource methods:

  • getCurrentTimelineEntryForComplication, and optionally from
  • getTimelineEntriesForComplication if time travel is supported.

Installing or removing a watch app has nothing to do with the placeholder template.

For watchOS 3:

watchOS 3 supports a face gallery which can let the user see and customize watch faces and complications. The static complication data shown in the gallery also comes from the placeholder template.

  • I'm running the watchkit app scheme on an iPhone + Apple Watch simulator. I also added breakpoints in all the methods you mentioned. The execution doesn't reach the breakpoint in `getPlaceholderTemplateForComplication`method as you described. I tried customizing the watch face and scrolling through complications. My complication shows up empty. Do I need to reset the watche's cache somehow? I've tried resetting content and settings in the simulators. – Julius Jun 30 '16 at 10:33
  • It won't reach that breakpoint, because you're not debugging what the watch is doing when it is customizing the watch face. The system has instantiated an instance of your complication controller, but you can't attach to it or interactively debug it. But debugging isn't really the issue. Perhaps you should edit your question and describe what you mean by your complication showing up as "empty." During customization of the watch face, or while active on the watch face? –  Jun 30 '16 at 10:44
  • Do you mean the simulator can run past breakpoints? In my experience it totally reaches the breakpoints sometimes, but not always. Also, by empty I mean that when I scroll to my complication in customization mode, my complication's name is shown next to the container, but the container is empty. Meaning that the system never cached the complication templates. – Julius Jun 30 '16 at 13:50