Detecting When watchOS 3 App Goes from Dock to Full Screen

In WWDC video 208 - Designing Great Apple Watch Experiences, starting at about the 13:25 mark, the presenter describes the Dexcom G5 Mobile App which displays some custom information in the doc that's easier or more relevant for viewing in the dock. When the app goes full screen, the app transitions to display different information. I would like to do something similar but I've not been able to figure out how to catch when my app goes full screen from the dock.


So far in a WKSnapshotRefreshBackgroundTask I've been able to push an interface controller I'd like to display when my app is viewed in the dock, but I'd like to dismiss that controller when my app goes full screen. I was hoping to piggy back off of willActivate, didAppear or willEnterForeground but those can happen long before my app actually goes full screen. In fact, I found that willActivate and didAppear are called during the WKSnapshotRefreshBackgroundTask when my interface controller is presented, while running in the background. Later when I press the dock button on the side of the watch and my app appears in the dock, my app receives willEnterForeground even if I don't actually open my app. In other words, just bringing up the dock and scrolling through the apps in the dock sends willEnterForeground to the apps. Does watchOS 3 send my app some other message or trigger when the user actually opens my app from the dock? I'm basically looking for some "hook" so that I can dismiss the controller.


Perhaps this is an enhancement request for a didEnterForeground method but it appears that in the WWDC video the Dexcom app received some message/trigger when the app went full screen.

Replies

As follow up I did attempt to use didBecomeActive but it seems like if you press the dock button and show the app in the dock, while the app does receive willEnterForeground, it does NOT receive appDidBecomeActive. If you open the watch app from the home screen it does receive didBecomeActive. Perhaps not receiving didBecomeActive when the app has been shown in the dock is simply a bug.

Any luck figuring this out?


One minor correction, WWDC video 208 was What's New in watchOS 3. I knew I saw this behavior before, but couldn't find it. Thanks for putting in the video #.

I'd like to respond but every time I type in my response the forum software says "The message contains invalid characters." I'll try to break my response down into small pieces.

After I posted here I eventually removed all my debug and logging code and everything just worked. I was surprised. However, I would occasionally still see the failure. So most of the time my extension does receive applicationWillEnterForeground but I'd say less than 5% of the time it does not. Because I can never be sure my extension will receive applicationWillEnterForeground I decided to set the title to "Close". Most of the time when my app comes up the controller disappears but when it doesn't, the user can just press "Close". I don't like having "Close" but it's better than leaving the user stuck with a modal controller on the screen and no way to dismiss it.


I did file a radar. Apple said it's a bug. They suggested I call dismissController in didDeactivate as watchOS should have taken the snapshot before or by the time didDeactivate is called. I tried that but it did not work for me. My special glance interface controller was never snapshotted. It had somehow always disappeared. So I just stuck with my "Close" workaround.