Is it possible to use the Screen Time API in the background using silent push?

When a request comes from the server, I want to set the screen time API of the requested phone or retrieve usage information. I would like to use silent push to complete that action in the background.

Is it impossible for the Screen Time API to run in the background?

Answered by Engineer in 796517022

If (more on that below) and when your app is activated using a silent push, you would be able to use certain ScreenTime APIs, like modifying the screen time restrictions by updating a ManagedSettings database.

But responding to screen time events, for example, is done in the app's extensions and you would need to wait for those to execute. You cannot use silent push or any other trigger to react to those events.

In any case, using silent pushes may not be as fruitful as you think it will be. Silent pushes are heavily throttled, could be delayed, and while you can expect 1-2 silent pushes an hour to reach your app, it is totally possible that none do.

Silent pushes are meant to signal the app that some data may have been changed, and are not suitable to use if you need to execute code immediately and consistently after sending them.

Accepted Answer

If (more on that below) and when your app is activated using a silent push, you would be able to use certain ScreenTime APIs, like modifying the screen time restrictions by updating a ManagedSettings database.

But responding to screen time events, for example, is done in the app's extensions and you would need to wait for those to execute. You cannot use silent push or any other trigger to react to those events.

In any case, using silent pushes may not be as fruitful as you think it will be. Silent pushes are heavily throttled, could be delayed, and while you can expect 1-2 silent pushes an hour to reach your app, it is totally possible that none do.

Silent pushes are meant to signal the app that some data may have been changed, and are not suitable to use if you need to execute code immediately and consistently after sending them.

If silent push notifications are not recommended, what alternative methods can ensure immediate and consistent code execution after a push notification is sent? We were advised to use the UNNotificationServiceExtension in a forum post, but it doesn’t allow access to managed settings or essential functionalities like Device Activity.

Is it possible to use the Screen Time API in the background using silent push?
 
 
Q