如何在iOS设备上获得屏幕时间?
我们目前正在构建一个iOS应用程序,该应用程序在其iOS设备上跟踪用户的屏幕时间。我了解Apple非常限制,并且当前的屏幕时间API是通过父母设置访问的。有什么办法可以在用户的屏幕时间获得基本信息?即使是像一天中的总屏幕时间这样的信息也可以做到。
We are currently working on building an iOS app that tracks the screen-time of the user on their iOS device. I understand that apple is very restrictive and the current Screen-Time API is any accessible through Parental Settings. Is there any way we can get basic info on the screen time of the user? Even info like total screen time of the day will do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信,苹果的屏幕时间API并未提供报告作为其功能之一。
在另一个问题中答案:链接。
另请参见有关此信息的WWDC视频:链接
I believe that Screen Time API from Apple does not offer a report as one of their capabilities.
Answer in other question: Link.
Also see WWDC video about this: Link
是的,可以使用屏幕时间API获取屏幕时间数据,该屏幕时间数据包括三个框架:
,您可以检索屏幕时间信息。
要将其集成到Xcode iOS项目中,请转到文件 - >新 - >目标 - >设备活动报告扩展。这将在您的项目中添加设备活动报告扩展目标,自动创建三个文件:
以显示用户的整体屏幕时间,将以下代码添加到任何视图文件中。这将促使用户许可并在批准后显示其屏幕时间。
此代码将调用TotalActivityView.swift文件。
欢呼!屏幕时间将显示。
Yes, it is possible to get screen time data using the Screen Time API, which comprises three frameworks:
With these three frameworks, you can retrieve screen time information.
To integrate this in an Xcode iOS project, go to File -> New -> Target -> Device Activity Report Extension. This will add a Device Activity Report Extension target to your project, automatically creating three files:
To display the overall screen time of the user, add the following code to any view file. This will prompt the user for permission and, upon approval, display their screen time.
This code will call the TotalActivityView.swift file.
Hurray! the screen time will be displayed.
没有对冲,这是不可能的。我们可以证明它仅在扩展名中
共享屏幕时间从设备活动扩展到您的父应用程序。我尝试过多种方法来实现UserDefault,AppGroup,Notification Center,但我无法将其输入我的应用程序。反对违规。是的,我检查了其他显示其应用中屏幕时间的应用程序,但是
我相信这是用户从应用程序中计算出的屏幕时间。
No hedgy it's not possible. We can show it's in only extension
Share screen time from Device activity extension to your parent app is not possible. I have tried multiple ways to achieve like Userdefault, Appgroup, Notification Center but i am not able to get that into my App. It's against violation. Yes i check other apps which shows screen time in their app but
i believe it's user estimate screen time which they calculate from app.