I have posted a question on
https://developer.apple.com/forums/thread/724437
The apple staff Kmart offerred me very helpful suggestions. However, i cannot leave a comment below it ( i am confused now)
Following the apple staff Kmart's instuction, i submit a feedback and request TSI with. a sample Xcode project on (https://github.com/orcas1202/sample_for_TSI)
However, TSI replied that it is still under investigation.
So, i am here to find some support. Would you please take a look at the very sample project.
Thanks in advance.
Post
Replies
Boosts
Views
Activity
I have followed the two videos about Screen time API in wwdc 21 and 22. Now i want to sheild some apps during sleeping, but I encounter some problems.
Problem I faced
I write my monitor and override intervalDidStart and intervalDidEnd . Here is a simplified version
class Mymonitor: DeviceActivityMonitor {
let store = ManagedSettingsStore()
override func intervalDidStart(for activity: DeviceActivityName) {
super.intervalDidStart(for: activity)
store.shield.applications = selection.applicationToken
}
then I use deviceActivityCenter to start monitor
func StartSleep (_ startTime : DateComponents)
{
let schedule = DeviceActivitySchedule(intervalStart: startTime,
intervalEnd: DateComponents(hour: 4, minute: 0),
repeats: true
)
let center = DeviceActivityCenter()
center.stopMonitoring([.daily])
try! center.startMonitoring(.daily, during: schedule)
}
However, when I use StartSleep. The applications is not shielded. I have noticed that I haven't use Mymonitor in any place. In the demo Code, it seems i just need to finish two parts (DeviceActivityMonitor and DeviceActivityCenter).
But in the DeviceActivityCenter i do not use Mymonitor. Then how can i triggger intervalDidStart that i overwrited?
Do i miss other details. Where can i use Mymonitor?
Troubleshooting
I have successfully shield apps using store.shield.applications = selection,applicationToken directly.
Thanks for your reading and help!