我的IOS应用程序从蓝牙心率传感器读取心率,心率显示在Apple Watch上 . 一切正常 . 但在大多数情况下,用户将锁定iPhone并将其放入口袋 .
这是问题所在:
IOS应用程序仍然在后台工作并读取心率,但我无法再在Apple Watch上显示数据,因为模拟器显示“Unlock to activate” .
当iPhone被锁定且IOS应用程序在后台时,是否无法继续使用WatchKit应用程序?
当谈到让iPhone在后台执行操作时, openParentApplication 非常有效 . 基本上, openParentApplication 将在手机锁定时运行 .
openParentApplication
此链接:http://www.bignerdranch.com/blog/watchKit-extensions-communicating-with-your-parent-application/
有一个我发现的最好和最容易理解的教程 . 真的帮帮我了,希望有所帮助 .
您应该能够使用 openParentApplication 获取数据
祝好运
I found the correct answer at the Apple Developer Forum:
问:如果您想在WatchKit应用程序或Glance中的特定接口控制器中调试willActivate / didDeactivate,一旦它在iOS模拟器中显示,您可以从iOS模拟器菜单栏中选择硬件>锁定以触发didDeactivate . 重复解锁并触发willActivate .
我在beta4中发现了这个,但有些混乱 . 它只是模拟器中的测试功能吗?真正的 Watch 上的应用程序在iPhone锁定后不会被锁定,对吧?
答:正确,它只是用于测试 .
问: Is there a way to test the watch app in the simulator while the phone is locked? 看起来这也是一个重要的测试案例,但是现在 Watch 仅在手机锁定时显示"unlock to activate" .
A: Not currently.
链接:(但你有一个开发者帐户)https://devforums.apple.com/message/1106203#1106203
你尝试过这样的事吗:Easy way to update app content via apple watch
当iPhone被锁定时,调用 openParentApplication 不起作用吗?
活动后台模式,以确保父应用程序有时间发送其回复 . 有关如何使用后台模式的代码示例,请参阅Calling parent application from Watch app .
4 回答
当谈到让iPhone在后台执行操作时,
openParentApplication
非常有效 . 基本上,openParentApplication
将在手机锁定时运行 .此链接:http://www.bignerdranch.com/blog/watchKit-extensions-communicating-with-your-parent-application/
有一个我发现的最好和最容易理解的教程 . 真的帮帮我了,希望有所帮助 .
您应该能够使用
openParentApplication
获取数据祝好运
I found the correct answer at the Apple Developer Forum:
问:如果您想在WatchKit应用程序或Glance中的特定接口控制器中调试willActivate / didDeactivate,一旦它在iOS模拟器中显示,您可以从iOS模拟器菜单栏中选择硬件>锁定以触发didDeactivate . 重复解锁并触发willActivate .
我在beta4中发现了这个,但有些混乱 . 它只是模拟器中的测试功能吗?真正的 Watch 上的应用程序在iPhone锁定后不会被锁定,对吧?
答:正确,它只是用于测试 .
问: Is there a way to test the watch app in the simulator while the phone is locked? 看起来这也是一个重要的测试案例,但是现在 Watch 仅在手机锁定时显示"unlock to activate" .
A: Not currently.
链接:(但你有一个开发者帐户)https://devforums.apple.com/message/1106203#1106203
你尝试过这样的事吗:Easy way to update app content via apple watch
当iPhone被锁定时,调用
openParentApplication
不起作用吗?活动后台模式,以确保父应用程序有时间发送其回复 . 有关如何使用后台模式的代码示例,请参阅Calling parent application from Watch app .