Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically get application usage from Screen Time in iOS 12

I am working on one project and I want to get other application usage time. apple has launched iOS 12 and provides the new feature Screen Time. I want to know is there any way or API provided by Apple to get data from it.

like image 225
Hemant Solanki Avatar asked Sep 24 '18 04:09

Hemant Solanki


People also ask

How do you check time spent on apps on iPhone?

View your Screen Time report After you turn on Screen Time, you can view a report of your device use with information including how much time you spend using certain kinds of apps, how often you pick up your iPhone and other devices, what apps send you the most notifications, and more. Go to Settings > Screen Time.

Does Screen Time count apps running in background?

The usage time of an app will not be calculated when it is running in the background or after it is stopped.


Video Answer


2 Answers

No, on iOS each app runs in its own sandbox and cannot see data from other apps, even apps from the same publisher. An app can access special shared data, like photos from the album or contact data, but it is not possible for an app to directly access files written by other apps.

ScreenTime application is on another sandbox than your app. Unless apple provide API we can't access the same.


Update

Since apple have added screen time app into ios12 simulator. There could be a chance they provide the API's soon.

like image 197
Saranjith Avatar answered Oct 17 '22 07:10

Saranjith


On iOS 15 Apple has added an API, see here: https://developer.apple.com/documentation/FamilyControls

FamilyControls

Authorize your app to provide parental controls on a child’s device. To authorize your parental controls app, use a shared AuthorizationCenter instance. You can authorize parental controls only on a device that is part of a Family Sharing group and signed into a child’s iCloud account.

You must add the Family Controls capability to your app.

like image 23
zvi Avatar answered Oct 17 '22 08:10

zvi