Hi, regarding the ScreenTime API or another API is there a way to count the time spent since the user unlocked their iPhone regardless of which app they are using?, and is it possible to detect while your app has/hasn't been launched and is/isn't running in the background?
Use case: App detects time spent using device has exceeded certain threshold and notifies the user with a Notification.
Note: I'm not interested in Family Control kind of app.
Thanks!
Yes, you can build a Device Activity monitor extension. Then, your app can start monitoring the user's device activity by using a DeviceActivityCenter
and your extension will get callbacks even when your app is in the background. In order to monitor all usage (regardless of which app is used), you can create a DeviceActivityEvent
without specifying any applications
, categories
, or webDomains
in the initializer.