Screen Time

RSS for tag

Share and manage web-usage data, and observe changes made to Screen Time settings by a parent or guardian.

Posts under Screen Time tag

160 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Multiple Days Schedules • Screen Time API
Hello, I wasn't able to figure out how to handle multiple days with DeviceActivitySchedule. For instance, let's say the user wants to block certain apps from 9:00 AM to 12:00 AM, every day except Saturday and Sunday, how my schedule should look like? I've tried different things... This schedule works for each day of the week, but that's not my goal: let schedule = DeviceActivitySchedule( intervalStart: DateComponents(hour: 9, minute: 00), intervalEnd: DateComponents(hour: 12, minute: 00), repeats: true) And if I specify the weekDay inside the DateComponents, like this: // Gregorian calendar // 2 -> Monday // 6 -> Friday let schedule = DeviceActivitySchedule( intervalStart: DateComponents(..., weekday: 2), intervalEnd: DateComponents(..., weekday: 6), repeats: true) the schedule will block the apps from Monday at 9:00 AM to Friday at 12:00 AM, which is also not my goal. The only workaround that came to my mind was to create a different schedule for each day of the week: enum WeekDays: String, CaseIterable { case sun, mon, tue, wed, thu, fri, sat var sortOrder: Int { switch self { case .sun: return 1 case .mon: return 2 case .tue: return 3 case .wed: return 4 case .thu: return 5 case .fri: return 6 case .sat: return 7 } } } func startMonitoring(weekDays: [WeekDays]) { for weekDay in weekDays { let day = weekDay.sortOrder let schedule = DeviceActivitySchedule( intervalStart: DateComponents( hour: 9, minute: 00, weekday: day), intervalEnd: DateComponents( hour: 12, minute: 00, weekday: day), repeats: true) let activityName = DeviceActivityName(weekDay.rawValue) do { try center.startMonitoring(activityName, during: schedule) } catch { print("DEBUG: Error: \(error.localizedDescription)") } } } This way I kinda get what I want, for example: I can specify 3 days of the week, let's say Monday, Tuesday and Wednesday, the time interval, let's keep 9:00 AM - 12:00 AM, and this function will block apps on Monday, Tuesday and Wednesday at that time interval, fine. However... What if I also want another schedule that blocks at a different time interval but same day? For example, I want to block certain apps Monday and Tuesday from 2:00 PM - 6:00 PM. Following the example above the activityName would be overwritten, so the user ( for Monday and Tuesday ) would now have only the schedules that starts from 2:00 PM. Basically, I want the user to be able to select multiple days for a schedule and to let them create as many schedules as they want. Does anybody know the correct way to handle multiple days schedules?
4
0
1k
May ’24
HELP ScreenTime API DeviceAcivityReport continious issues
Hi everyone, I've been spending my evenings on the app for around 6 months that's using Screen Time API introduced in WWDC 21 (https://developer.apple.com/videos/play/wwdc2021/10123/), I'm having many issues with this API and looking for anyone who has experience with this API, I will appreciate any help or advice I can get! I'm using DeviceActivityReport to display the dashboard with screen time usage and certain metrics. Device activity report extension runs in an isolated sandbox, which makes it harder to debug and can't make any network call or write to any storage, for privacy purposes which makes sense, but makes it very hard for development. The issue is that the process where DeviceActivityReport is running crashes for no reason frequently or doesn't run at all. The API itself has many bugs, which is backed up by my experience, Opal app developers and Screen Time even made the news with its bugs. I see the same behaviour with other apps like Opal, but they can workaround somehow it and reload the report. I'm experienced with UIKit but have little experience with SwiftUI, since ScreenTime API is using SwiftUI only I have to embed DeviceActivityReport in UIKit using UIHostingController and then inside of the device activity report extension target I'm using UIViewControllerRepresentable to embed UIKit into SwiftUI. But I've done some testing and the behaviour is the same when using pure SwiftUI, although there might be fewer hiccups, I couldn't rewrite the whole app. That's the gist, there's too much code to include, but I can drop more code snippets if there's anyone who has experience with this API who can help me.
2
1
737
Nov ’23
Screen Time Api
Hi Folks, How to sheild or lock the apps in childs phone from the Guardians Phone. I got the opaque tokens from childs phone , but on the parents device there are only categories options but not the applications. so how to get the applications in parentsl device . when i try to authorisee the family controls with .individual option there are not the applications in family activity picker but only the categories and others. Thanks in advance
0
0
330
Nov ’23
Device Activity Report View Size and Background
Hello! I am a new developer and am attempting to use Apple's Device Activity API. However, I am struggling with the View of the Device Activity Report. For one, the view stretches to fill all available space instead of simply being the size of its content. Secondly, the background color seems fixed and I can't figure out how to remove it. The Screen Time API demo video shows this Device Activity API used with a clear background, so I know it is possible, I just can't figure out how to do it as it seems to be built into the Device Activity Report itself. Does anyone have any ideas? I'll attach a photo to show you what I mean. The black box is the Device Activity Report that I am trying to edit. Thank you for your help!
6
1
803
Dec ’23
Screen Time API fails to unblock the apps, and leaves an hourglass shield that doesn't allow unshielding
DL;DR: Sometimes the API fails to unblock the app and leaves an hourglass shield on the restricted apps, which is not set by us. Even worse, if we remove authorization of our app from Settings, the restricted apps remain locked until we restart the phone or re-run our app from Xcode. Our app monitors the usage of selected apps from the current time until the reset time at 4:00 a.m. When the given threshold is reached, the selected apps are shielded. After the user taps the close button on the shield view, we attempt to remove the shield, set up a new threshold monitoring and close the app. The issue is that: sometimes the shield removal fails, and after the app closes itself, it remains shielded, and displays an hourglass shield view that was never in our shield configuration. Additionally, regardless of what we do-removing the shielding from our apps or removing the authorization of our app from Settings, the restricted apps remain shielded until we restart the phone or re-run our app from Xcode. Code I use for un-shielding: warningUsageStore.clearAllSettings() Code I use for scheduling the threshold: var warningMinute = userDefaults.integer(forKey: .warningMinute) if warningMinute <= 0 { warningMinute = 5 } let selection = familyActivitySelection() let now = Date.now let start = Calendar.current.dateComponents([.hour, .minute, .second], from: now) var end = AppConfig.resetEndTime // use twenty minutes later as the end time if the before reset time is too near e.g. warning start at 3:55 but reset time is 4:00 if let endDate = Calendar.current.nextDate(after: now, matching: end, matchingPolicy: .nextTime), endDate.timeIntervalSince(now) <= 15*60 { end = Calendar.current.dateComponents([.hour, .minute, .second], from: now.addingTimeInterval(20*60)) } // add inidividual event according to the hash value to dintinguish between apps. var events = [DeviceActivityEvent.Name : DeviceActivityEvent]() for application in selection.applications where application.token != nil { events[.init(application.hashValue.description)] = .init(applications: [application.token!], threshold: .init(minute: warningMinute)) } for category in selection.categories where category.token != nil { events[.init(category.hashValue.description)] = .init(categories: [category.token!], threshold: .init(minute: warningMinute)) } for webDomain in selection.webDomains where webDomain.token != nil { events[.init(webDomain.hashValue.description)] = .init(webDomains: [webDomain.token!], threshold: .init(minute: warningMinute)) } try deviceActivityCenter.startMonitoring(.usageWarning, during: .init(intervalStart: start, intervalEnd: end, repeats: false), events: events) The issue happens on my iPhone11 iOS17.1.2 Any insight would be much appreciated. Thank you!
0
1
505
Dec ’23
How to use Screen Time API
Hi guys, I am trying to build an app that blocks access to a set of apps defined by a user. Pretty typical app blocking functionality, but I can't find any info about the Screen Time API. I've narrowed it down to DeviceActivity and MangedSetting frameworks but am unsure of which to use. Also, is there a way to get a list of the installed apps on a user's device, or will I have to manually set that?
0
0
346
Dec ’23
AuthorizationCenter.shared times out and makes my ScreenTime App Unusable
Any way that I try requesting authorization for family controls is incredibly inconsistent. The line of code that hangs is **let center = AuthorizationCenter.shared ** I've looked at other posts and I saw someone recommended declaring let center = AuthorizationCenter.shared outside the main thread and somehow get the status on the main thread. I've tried that approach with no success. I've scoured GitHub to see how other people approach the request but it's all pretty similar. The following code sometimes works great for a few minutes and then I rebuild and run and it hangs on AuthorizationCenter.shared.requestAuthorization(for: FamilyControlsMember.individual). Would love any suggestions!!! .onAppear { Task { do { print("try requestAuthorization") try await AuthorizationCenter.shared.requestAuthorization(for: FamilyControlsMember.individual) print("requestAuthorization success") switch AuthorizationCenter.shared.authorizationStatus { case .notDetermined: print("not determined") case .denied: print("denied") case .approved: print("approved") @unknown default: break } } catch { print("Error requestAuthorization: ", error) } } }
0
0
475
Dec ’23
Activity log app on iPhone?
Hey. Is there any app that shows a precise activity log? When I was using Android I had an app Quality Time which keeps the track of what are you doing minute by minute. It has a log which shows 13:24 PM Open Facebook, 13:45 Open Instagram etc. Is there any app on iPhone that tracks your activity like this and stores it into a log or something? I need an app like this or something similar Thank you.
0
0
603
Dec ’23
App Usage
I'm developing a mental wellness app, and I need to get user's screentime and app usage data and send it to my flask backend for analytics. Is it possible on iphone right now? I've looked into ScreenTime and DeviceActivity frameworks, but they're really poor in terms of examples and documentation, so I'm not sure if this is actually possible or not.
0
1
344
Dec ’23
Limiting / Blocking App Access to FamilyActivitySelection for 30 minute interval
Hello, I am able to have users properly select apps that my app can limit and block, however I am having a lot of trouble figuring out how to restrict access for set periods of times. For example, I want the user to select the apps they wish to block, store them so they can be reused later and whenever they press a button restrict access for the next 30 minutes. I understand this is doable if they are actively on the app, but I do not know how to automate the lifting of this restriction after the given period. Moreover, what is the best way to persist the category and application tokens selected via the FamilyActivitySelector?
0
0
346
Dec ’23
Providing Pre-Selections to FamilyActivityPicker?
I am able to correctly select and store the tokens of apps and categories my users will block, but I am unable to pre-populate Picker whenever the app is rebooted with previously selected and stored tokens. Below is the selection variable I am passing to the picker... var selectionsToBlock = FamilyActivitySelection() { willSet { saveSelection(selection: newValue) blockersSelected = true } } Is there any way I can provide my existing blockers (shown below) so that the user can easily edit their list of restricted apps from the Picker? func savedBlockers() -> FamilyActivitySelection? { let defaults = UserDefaults.standard guard let data = defaults.data(forKey: userDefaultsKey) else { return nil } return try? decoder.decode( FamilyActivitySelection.self, from: data ) }
2
0
529
Feb ’24
FamilyActivityPicker Crashing / Freezing
Our users report frequent crashes with the FamilyActivityPicker. Since this is a screen controlled by Apple, I'm assuming that there's nothing I can do to prevent these crashes. I'm wondering, though, if there's any way to gracefully handle these crashes? When this happens, the following is printed to the console: [com.apple.FamilyControls.ActivityPickerExtension(1121)] Connection to plugin invalidated while in use. Does anyone know how to handle/catch this error?
2
2
636
Jan ’24
Authentication (FaceID or Passcode) prompt is not triggered after Screen Time's "Time Limit" is extended
When trying to open an app that uses Local Authentication (FaceID) the auth process does not start right away, 3-4 times trying to auth is needed in order to get authenticated with the method the user has selected (FaceID), this is happening with many apps and seems that there's no a workaround. [Edited by Moderator]
1
0
575
Jan ’24
4+ weeks of waiting for Family Controls Entitlement
Over a month ago, I submitted the Family Controls Entitlement form: https://developer.apple.com/contact/request/family-controls-distribution For an app I'm developing and I've received 0 feedback. No case number, no email and I've called and emailed support 3 times but they haven't been able to help me. When can I expect to hear back from the Family Controls team, what's the average wait time.
4
3
699
Feb ’24
Screen Time Issue - Can't allow 3rd party aps
Experiencing a very strange issue with 3rd party permissions not working on screen time as of yesterday on my device (iPhone 12, iOS 17.2.1) and we are concerned that other users may end up dealing with this if it's not resolved. The video attached demonstrates what I mean but this is happening across every single screen time application, not just Opal or ours. I tried resetting my device, hard reboots, deleting and redownloading the apps, updating my phone, and turning screen time off and back on but nothing has worked. I also submitted my feedback (FB13540567)
1
1
345
Jan ’24
App with DeviceActivityReport extension either won't install on device or won't upload to TestFlight
We have integrated DeviceActivityReport to our Family Controll app. All capabilities are added. We built the app and tested it, but when we want to upload to TestFlight the following error happened (see attached image) When we are adding NSExtensionMainStoryboard or NSExtensionPrincipalClass the following error appears during installation process. DeviceReport.appex with id com.example.example.DeviceReport defines either an NSExtensionMainStoryboard or NSExtensionPrincipalClass key, which is not allowed for the extension point com.apple.deviceactivityui.report-extension
1
0
438
Jan ’24