WatchKit app “Unlock to activate”

时间秒杀一切 提交于 2019-12-07 20:50:36

问题


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?


回答1:


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




回答2:


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?




回答3:


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




回答4:


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.



来源:https://stackoverflow.com/questions/29156127/watchkit-app-unlock-to-activate

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!