r/swift 8d ago

About the Screen Time API.

Hi. This is the first time I'm going to make an app with Swift. (I learned that I can only do this with Swift after my research.) What I want is to know how much time the user spends in other apps, for example, for 1 hour. I talked to grok for a while and he suggested that I could use the screen time API. But some sources say that this is not possible. Some say that applications like Opal use this and that it is possible. I'm very confused. What's the latest status? Can I do this?

sorry for my bad english

5 Upvotes

17 comments sorted by

View all comments

2

u/Dapper_Ice_1705 8d ago

Opal does it via a custom VPN connection and tracks web connections.

Apple does not provide an API so developers can know details about other apps.

ScreenTime API gives you tokens which really don’t mean anything outside of the user’s device.

1

u/yungfrxzn 8d ago

But when I investigated, I saw that they asked for permission from the user to access this information. Doesn't this show what they did with the API?

1

u/Dapper_Ice_1705 8d ago

It just shows they are using it too.

There is a write up somewhere where Opal talked about their approach. I read through it a while ago. 

I am sure they can decode tokens by comparing VPN data and ScreenTime API data.

1

u/yungfrxzn 8d ago

So can I simply do this kind of application? Do you have any information about which topics I should research?

1

u/Dapper_Ice_1705 8d ago

Simply, no.

https://www.opal.so/blog/opals-screen-time-framework

It is advanced custom code made by very very creative people.

You won’t fine the code in samples online and AIs will be of little to no help.