Limit app usage with Screen Time API

I wanted to create an app that based on some conditions would limit some apps usage via Screen Time. I know that with the Screen Time API it is possible to limit apps only if there is a guardian or a parent in the family, but I need to limit usage directly on the user device without a guardian or parent. Is there any way to do it?

Answered by Claude31 in 708955022

Just an idea.

You could measure how long the app is in foreground (in a given time period).

Then when the threshold is exceeded, you quit the app (gracefully of course) after saving in UserDefaults.

When user relaunches the app, check UserDefaults and let him/her know if use time is exceeded and then quit again.

Take care if doing so of guideline 3.2.2 (vi):

(vi) Apps should allow a user to get what they’ve paid for without performing additional tasks, such as posting on social media, uploading contacts, checking in to the app a certain number of times, etc. Apps should not require users to rate the app, review the app, watch videos, download other apps, tap on advertisements, enable tracking, or take other similar actions in order to access functionality, content, use the app, or receive monetary or other compensation, including but not limited to gift cards and codes.

Accepted Answer

Just an idea.

You could measure how long the app is in foreground (in a given time period).

Then when the threshold is exceeded, you quit the app (gracefully of course) after saving in UserDefaults.

When user relaunches the app, check UserDefaults and let him/her know if use time is exceeded and then quit again.

Take care if doing so of guideline 3.2.2 (vi):

(vi) Apps should allow a user to get what they’ve paid for without performing additional tasks, such as posting on social media, uploading contacts, checking in to the app a certain number of times, etc. Apps should not require users to rate the app, review the app, watch videos, download other apps, tap on advertisements, enable tracking, or take other similar actions in order to access functionality, content, use the app, or receive monetary or other compensation, including but not limited to gift cards and codes.

Limit app usage with Screen Time API
 
 
Q