SCREEN TIME API
SCREEN TIME API
Review Notes Prepared by :- Amit Sinha
Screentime API provides a certain amount of time to be spent in Particular Application.
Like : Parents - If they are allowed to use any Application to their Children. So they can only allow certain amount of time to particular Application,
Example: Facebook - 2hr. (So Children can access the application for 2 Hours). If they reached their threshold time then Shield will Appear Every Time.
SetUp Screen Time API
Developer Note
On your Mac go to > System Preferences > Open Family Sharing
Add a child account (iTunes Account - Child Should be less than 13 Years old)
Sign in as the child on your iPhone Real Device
Family Sharing Setup
We have to use a Physical device where we are using a Parents & ChildAccount.
If you are using a Simulator then it will hit Error.
As well as we have to use the Upgraded System ios 15.0 beta & XCode 13 Beta.
After Entering Parent’s or Guardian Apple ID. We are getting a Successful Message.
After Getting Successful Message now we are able to fetch the Application Details.
FamilyActivityPicker
A view that lets users select categories, applications, and web domains for parental controls, while protecting the user’s privacy.
Research
Screen Time API
iOS 15
Swift compatible with ScreenTimeApi.
Managing the Threshold Time
There are three ScreenTime API Frameworks:
Family Controls - Authorize your app to provide parental controls on a child’s device.
Device Activity: Monitor device activity with your app extension while maintaining user privacy. (It will provide all the Data of Child Device to guardian and Maniting the User Privacy)
ManagedSettings: It provides parental control over the Application. Parents can change settings of your Apps & devices.
ManagedSettings UI : We can configure your Shield view using ManagedSettings UI. It provided the functionality of shield configuration, where we properly configure the shield.
FamilyActivityPicker
A view that lets users select categories, applications, and web domains for parental controls, while protecting the user’s privacy.
On the Basis user can get the Details of Categories with Application list.
FamilyActivitySelection:
A collection of applications, categories, and web domains selected by the user. On the basis users can select a particular app or category to provide lock & unlock functionality.
DeviceActivityEvent:
An event that represents an application, category, or website activity.
DeviceActivitySchedule:
Create a new schedule using DateComponents that allows your app to monitor the user’s device activity during a period of time. You can set a schedule for your app to monitor on a regularly occurring basis. You can create a warning time that the system uses to provide your app extension with callbacks whenever a schedule is about to start or end, or when an event is close to reaching its threshold.
DeviceActivityMonitor - Shields
DeviceActivityMonitor this object used to monitor the scheduled DeviceActivity.
Your app can set up a schedule to monitor for deviceActivity
We have to define the Start and end Interval - DeviceActivityName()
You can execute device activity events when usage thresholds are met (e.g., if they spend enough minutes in guardian approved apps then restricted apps can be unlocked)
ShieldConfiguration
Customize the look (e.g., icon, background color)
DeviceActivityMonitor
DeviceActivityMonitor this object used to monitor the scheduled DeviceActivity.
override func intervalDidEnd(for activity: DeviceActivityName) {
super.intervalDidEnd(for: activity)
let schedule = DeviceActivitySchedule(
intervalStart: DateComponents(hour: dateComponents.hour,
minute: dateComponents.minute,
second: second),
intervalEnd: DateComponents(hour: 23, minute: 59, second: 00),
repeats: true
)
startTimerTime = "\(DateComponents(hour: dateComponents.hour, minute: dateComponents.minute, second: second))"
endTimerTime = "\(DateComponents(hour: 23, minute: 59, second: 00))"
This type of Shield We are able to display on Lock Application. We are able to customize in shield upto - Adding logo, Adding Background color, Adding Text & Adding Button.
To Understand more concepts regarding ScreenTime. Please refer below Link to understand, What we can do with Screen Time API
Comments
Post a Comment