WatchKit app “Unlock to activate”

2019-05-23 21:58发布

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?

标签: ios watchkit
4条回答
三岁会撩人
2楼-- · 2019-05-23 22:03

Active background mode to ensure that the parent app has time to send its reply. For a code example on how to use the background mode, refer to Calling parent application from Watch app.

查看更多
虎瘦雄心在
3楼-- · 2019-05-23 22:09

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

查看更多
Deceive 欺骗
4楼-- · 2019-05-23 22:13

When it comes to getting the iPhone to perform things in the background, openParentApplication works very well. Essentially, openParentApplication will run while your phone is locked.

This link: http://www.bignerdranch.com/blog/watchKit-extensions-communicating-with-your-parent-application/

has one of the best and easiest to understand tutorials I've found. Really helped me out, hope that helps.

You should be able to grab your data using openParentApplication

Good luck

查看更多
不美不萌又怎样
5楼-- · 2019-05-23 22:20

Did you try something like this: Easy way to update app content via apple watch

Does calling openParentApplication not work when the iphone is locked?

查看更多
登录 后发表回答