Search code examples
ioswatchkit

WatchKit app "Unlock to activate"


My IOS app reads the heart rate from a bluetooth heart rate sensor, the heart rate is displayed on the Apple Watch. Everything works fine. But in most cases the user will lock the iPhone and put it in his pocket.

Here is the problem:

The IOS app is still working in the background and reading the heart rate but I can no longer display the data on the Apple Watch because the simulator displays "Unlock to activate".

Is it not possible to continue with the WatchKit app when the iPhone is locked and the IOS app is in the background?


Solution

  • I found the correct answer at the Apple Developer Forum:

    Q: If you would like to debug willActivate/didDeactivate in a specific Interface Controller in your WatchKit app or Glance, once it is showing in the iOS Simulator, you can choose Hardware > Lock from the iOS Simulator menu bar to trigger didDeactivate. Repeat to unlock and trigger willActivate.

    I found this in beta4, but some confusion. Is it just a test function in simulator? The app on real watch would not be locked after iphone locked, right?

    A: Correct, it's just for testing.

    Q: Is there a way to test the watch app in the simulator while the phone is locked? It seems like this would be an important test case as well, but right now the watch only shows "unlock to activate" while the phone is locked.

    A: Not currently.

    Link: (but you mast have a developer account) https://devforums.apple.com/message/1106203#1106203