xcode 如何防止Apple Watch进入睡眠状态?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35393307/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:32:15  来源:igfitidea点击:

How to prevent the Apple Watch from going to sleep?

xcodeswiftwatchkitapple-watchwatchos-2

提问by user3229261

We are working on an Apple Watch project, but the watch goes to sleep if uninterrupted with.

我们正在处理一个 Apple Watch 项目,但如果不受打扰,手表就会进入睡眠状态。

Is there any way to prevent it from going to sleep?

有什么办法可以让它不睡觉吗?

回答by Simply Me

As of my knowledge and other searches on this topic, at the moment is no apiavailable to enable or even disable sleep mode for Apple Watch programmatically.

据我所知和关于此主题的其他搜索,目前无法api以编程方式启用甚至禁用 Apple Watch 的睡眠模式。

回答by Seyyed Parsa Neshaei

No-Sleep API

无睡眠 API

Currently, there is no API to disable Apple Watch from going to sleep.

目前,没有 API 可以禁止 Apple Watch 进入睡眠状态。

You may wait until watchOS 3.

你可以等到 watchOS 3。

Changing Sleep Time By User

用户更改睡眠时间

Any user can go to this path:

任何用户都可以转到此路径:

Settings -> General -> Wake Screen

设置 -> 通用 -> 唤醒屏幕

And set the time to a long time.

并将时间设置为长时间。

Unfortunately, only the user can change this and there is no way to do it programmatically.

不幸的是,只有用户可以更改此设置,并且无法以编程方式进行更改。

NOTE: If you want the screen to resume your activity after waking up, you should ask user to do so here:

注意:如果您希望屏幕在醒来后恢复您的活动,您应该在此处要求用户这样做:

Settings -> General -> Wake Screen -> Resume Last Activity

设置 -> 通用 -> 唤醒屏幕 -> 恢复上次活动

Note that according to Owen, keeping the watch awake would kill the battery quickly.

请注意,根据 Owen 的说法,保持手表处于唤醒状态会很快耗尽电池电量。

Conclusion

结论

1- No API is set.

1- 未设置 API。

2- User can change sleep time.

2- 用户可以更改睡眠时间。

3- User can select to resume last activity when the Apple Watch wakes up.

3- 用户可以选择在 Apple Watch 唤醒时恢复上次活动。

回答by Owen Hartnett

Because of the power requirements, keeping the watch awake would kill the battery quickly. However, you may be concerned that when the watch does go to sleep, it doesn't re-wake to your app. This can be remedied at the user level, on your iOS device using the Watch App, using General->Wake Screen-> and checking "Resume Last Activity"

由于电源要求,让手表保持唤醒状态会很快耗尽电池电量。但是,您可能会担心当手表确实进入睡眠状态时,它不会重新唤醒您的应用程序。这可以在用户级别修复,在您的 iOS 设备上使用 Watch App,使用 General->Wake Screen-> 并选中“Resume Last Activity”