Screen Time

RSS for tag

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

Screen Time Documentation

Posts under Screen Time tag

160 Posts
Sort by:
Post not yet marked as solved
3 Replies
580 Views
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?
Posted
by Ivan018.
Last updated
.
Post not yet marked as solved
7 Replies
2.2k Views
When I tap on one of the buttons in the ShieldAction extension I want to close the shield and open the parent app instead of the shielded app. Is there any way of doing this using the Screen Time API? class ShieldActionExtension: ShieldActionDelegate {      override func handle(action: ShieldAction, for application: ApplicationToken, completionHandler: @escaping (ShieldActionResponse) -> Void) {     // Handle the action as needed.           let store = ManagedSettingsStore()               switch action {     case .primaryButtonPressed:       //TODO - open parent app       completionHandler(.defer)     case .secondaryButtonPressed:       //remove shield       store.shield.applications?.remove(application)       completionHandler(.defer)         @unknown default:       fatalError()     }   }   }
Posted
by mariusgab.
Last updated
.
Post not yet marked as solved
0 Replies
71 Views
Hi there, I'm currently working with the Screen Time API using the family controls package to manage application usage on iOS devices. I want to block access to all applications except those specifically allowed by the user. While the ManagedSettingsStore.shield.applications method works for defining apps to block. However, integrating the .all(except:) from ShieldSettings.ActivityCategoryPolicy.all(except:) is unfortunately not working for me. Here is my code snippit. Can anyone help out? And if anyone has examples of similar implementations or tips on best practices for using the Screen Time API for such scenarios, please let me know! class ShieldManager: NSObject, ObservableObject, NFCNDEFReaderSessionDelegate { @Published var discouragedSelections = FamilyActivitySelection() private let store = ManagedSettingsStore() func shieldActivities() { // Clear to reset previous settings store.clearAllSettings() // This is an array with the app and category selection let applications = discouragedSelections.applicationTokens let categories = discouragedSelections.categoryTokens // //https://developer.apple.com/documentation/managedsettings/shieldsettings/activitycategorypolicy store.shield.applications = applications.isEmpty ? nil : applications store.shield.applicationCategories = categories.isEmpty ? nil : .specific(categories) store.shield.webDomainCategories = categories.isEmpty ? nil : .specific(categories) } f
Posted Last updated
.
Post not yet marked as solved
0 Replies
163 Views
I am developing a parent child control app using Screen time API and Family Control. I created two apps, one for parent and another for child. I want to see child device's activity report on parent app. This functionality works when there is only one parent/organiser. I am trying to add multiple parents to access device activity report using screen time API. I created a family group where I am the organiser (Dad), added another account as parent (Mom) and two child accounts. On the child's device I installed the app, authorised the app for parental approval (Dad) and screen time restrictions. When using the parent app as Mom, I am unable to fetch the child device's activity report.
Posted Last updated
.
Post not yet marked as solved
0 Replies
134 Views
There is an inconsistent issue when views are rendered from the Device Activity Report Extension. This issue is noticeable only on release versions and it works fine in debug mode. Around 80% of the times, the Report Views return blank screen and this is only the case when a weekly/monthly filter is used. Although, it works as expected for daily report views. My questions are: How are all the Report Activity Views working fine in debug mode but not in release mode? How the daily activity filter works fine in the release mode but the weekly/monthly filters don't work? Is this because of a memory limit issue in the extension? As of now, I have the family-controls(distribution) entitlement only for the app and for the extensions I only have family-controls(development) entitlement. Do I need to request for family-controls(Distribution) entitlement even for the extensions? I have seen threads on the forum mentioning the blank screen issue associated with the DeviceActivityReport but haven't found a solution to it. Any suggestions/feedback would be of great help, thanks.
Posted Last updated
.
Post not yet marked as solved
1 Replies
153 Views
I've been working with the Screen Time API for almost 6 months now. I found out it's completely unreliable, testing on iOS 17.4, the DeviceActivityReport is not showing, the DeviceActivityMonitor more often than not does not fire intervalDidStart. It's very frustrating. Has anyone found out a workaround? We all know there has to be something we're doing wrong, since apps like Opal and Jono does not present those types of issues. Let's please unite our forces and find a solution. How to use this API should not be a secret!
Posted
by Ivan018.
Last updated
.
Post marked as solved
2 Replies
1.1k Views
There is frequently a delay of a few seconds before a DeviceActivityReport renders its view generated from the DeviceActivityReportExtension. It will also sometimes flash with zero data before hydrating with the real activity data (tested with extension code taken directly from XCode boilerplate) Is there a way to be notified when the DeviceActivityReport renders successfully or is still processing, i.e. so a loading indicator can be presented while the extension runs? Thanks!
Posted
by foijodsf.
Last updated
.
Post not yet marked as solved
0 Replies
170 Views
I am currently trying to build a prototype parental control app using the ScreenTime API. I was just wondering if I needed to create a separate parent and child app?
Posted
by wick_mma.
Last updated
.
Post not yet marked as solved
2 Replies
197 Views
Hi, we are facing issues with the FamilyActivityPicker. I have 2 devices in the same family, one successfully authorised as child device using AuthorizationCenter.shared.requestAuthorization(for: .child), the other one is used as parent device. When I invoke FamilyActivityPicker on the children's device it works as expected but when invoked on the parent's device it only shows list of categories but not a single app. This behavior doesn't occur every time, on some devices it sometime works as it should. It's very odd and I can't find any reason why it is happening. I would appreciate any tips. Tested on app built with Xcode 15.3 an run on iOS 17.4.1 and iOS 16.7.2
Posted Last updated
.
Post not yet marked as solved
0 Replies
150 Views
I am building an app that manages ScreenTime and I would like to persist the tokens of which apps are frequently limited to CoreData locally. I attempted to do so by converting to a string but was unable to find a way to initialize an ActivityCategoryToken with a string. Is this possible? Am I going about it the wrong way? Thanks.
Posted
by gweinz.
Last updated
.
Post not yet marked as solved
0 Replies
120 Views
I have an app on App Store and some users started seeing this bug when the app requests for Screen Time API usage. The error is "The data couldn't be read because it isn't in the correct format". But it works still for most users and I can't reproduce it on my device. Checking the competitors, some of them shows this error when requesting for ScreenTime usage: "An unknown error occurred: NSCocoaErrorDomain, 4864) Has anyone experienced this? Thank you! My code below requesting screen time authorization .onAppear { Task { do { try await center.requestAuthorization(for: .individual) if center.authorizationStatus == .approved { self.checkApproved() } else { state = .denied } } catch let error { showingAlert = true errorTitle = error.localizedDescription state = .denied } } }
Posted Last updated
.
Post not yet marked as solved
0 Replies
180 Views
I am developing a parental control app using Flutter and platform channels to integrate with the Screen Time API on iOS. The app has two interfaces - one for the parent and one for the child. I have set up Family Sharing correctly and installed the app on both the parent's and child's devices. However, I am encountering some issues with the Family Activity Selection feature. It's worth noting that I am a Flutter developer with limited knowledge of Swift and iOS development, so if my issues stem from a mistake I made, please forgive me. The problems I am facing are as follows: When calling the family activity selection, the list of apps shown in the apps sheet is from the parent's device, and no apps from the child's device are displayed. I have double-checked that Family Sharing and other necessary configurations are set up correctly, including the family control capability. Even if I select apps on the parent's device, the selected apps are not returned in the result. The returned array is empty. Additionally, there is no close or done button on the sheet, and drag-to-dismiss is not working either. This might be an issue with the way I have written the code (most of the native code was generated by AI assistants like Claude and GPT, as I am a Flutter developer with limited knowledge of Swift and iOS development). I have tested other parental control apps that use the Screen Time API and observed the same issue, where the parent's apps are shown on the parent's device instead of the child's apps. For more context, I have provided the relevant code snippet below: import Flutter import FamilyControls import ManagedSettings import SwiftUI class FamilyActivityHandler: NSObject, FlutterPlugin { // ... private func openFamilyActivityPicker(result: @escaping FlutterResult) { let store = ManagedSettingsStore() let selection = FamilyActivitySelection() // Adjusting for UIWindowScene for iOS 15 and later guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, let window = windowScene.windows.first else { result(FlutterError(code: "NO_WINDOW_SCENE", message: "No window scene found", details: nil)) return } let viewController = UIHostingController(rootView: FamilyActivityPicker(selection: .constant(selection))) viewController.modalPresentationStyle = .formSheet window.rootViewController?.present(viewController, animated: true, completion: nil) DispatchQueue.main.async { let applications = selection.applicationTokens let categories = selection.categoryTokens let webDomains = selection.webDomainTokens store.shield.applications = applications.isEmpty ? nil : applications store.shield.applicationCategories = ShieldSettings.ActivityCategoryPolicy.specific(categories, except: Set()) store.shield.webDomains = webDomains // Custom method to generate descriptive strings for tokens let applicationsDescription = applications.map { token in // Implement a custom description method or use an identifier property "\(token)" } let categoriesDescription = categories.map { token in // Implement a custom description method or use an identifier property "\(token)" } let webDomainsDescription = webDomains.map { token in // Implement a custom description method or use an identifier property "\(token)" } let resultDict: [String: Any] = [ "applications": applicationsDescription, "categories": categoriesDescription, "webDomains": webDomainsDescription ] result(resultDict) } } } I would greatly appreciate any guidance or insights from the community on how to resolve these issues and properly implement the Family Activity Selection feature using the Screen Time API in a Flutter app with platform channels. Thank you in advance for your help!
Posted
by amalshyjo.
Last updated
.
Post not yet marked as solved
0 Replies
160 Views
I am developing a parental control app using Flutter and platform channels to integrate with the Screen Time API on iOS. The app has two interfaces - one for the parent and one for the child. I have set up Family Sharing correctly and installed the app on both the parent's and child's devices. However, I am encountering some issues with the Family Activity Selection feature. It's worth noting that I am a Flutter developer with limited knowledge of Swift and iOS development, so if my issues stem from a mistake I made, please forgive me. The problems I am facing are as follows: When calling the family activity selection, the list of apps shown in the apps sheet is from the parent's device, and no apps from the child's device are displayed. I have double-checked that Family Sharing and other necessary configurations are set up correctly, including the family control capability. Even if I select apps on the parent's device, the selected apps are not returned in the result. The returned array is empty. Additionally, there is no close or done button on the sheet, and drag-to-dismiss is not working either. This might be an issue with the way I have written the code (most of the native code was generated by AI assistants like Claude and GPT, as I am a Flutter developer with limited knowledge of Swift and iOS development). I have tested other parental control apps that use the Screen Time API and observed the same issue, where the parent's apps are shown on the parent's device instead of the child's apps. For more context, I have provided the relevant code snippet below: import Flutter import FamilyControls import ManagedSettings import SwiftUI class FamilyActivityHandler: NSObject, FlutterPlugin { // ... private func openFamilyActivityPicker(result: @escaping FlutterResult) { let store = ManagedSettingsStore() let selection = FamilyActivitySelection() // Adjusting for UIWindowScene for iOS 15 and later guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, let window = windowScene.windows.first else { result(FlutterError(code: "NO_WINDOW_SCENE", message: "No window scene found", details: nil)) return } let viewController = UIHostingController(rootView: FamilyActivityPicker(selection: .constant(selection))) viewController.modalPresentationStyle = .formSheet window.rootViewController?.present(viewController, animated: true, completion: nil) DispatchQueue.main.async { let applications = selection.applicationTokens let categories = selection.categoryTokens let webDomains = selection.webDomainTokens store.shield.applications = applications.isEmpty ? nil : applications store.shield.applicationCategories = ShieldSettings.ActivityCategoryPolicy.specific(categories, except: Set()) store.shield.webDomains = webDomains // Custom method to generate descriptive strings for tokens let applicationsDescription = applications.map { token in // Implement a custom description method or use an identifier property "\(token)" } let categoriesDescription = categories.map { token in // Implement a custom description method or use an identifier property "\(token)" } let webDomainsDescription = webDomains.map { token in // Implement a custom description method or use an identifier property "\(token)" } let resultDict: [String: Any] = [ "applications": applicationsDescription, "categories": categoriesDescription, "webDomains": webDomainsDescription ] result(resultDict) } } } I would greatly appreciate any guidance or insights from the community on how to resolve these issues and properly implement the Family Activity Selection feature using the Screen Time API in a Flutter app with platform channels. Thank you in advance for your help!
Posted
by amalshyjo.
Last updated
.
Post not yet marked as solved
2 Replies
636 Views
Update 1: Seems like app limits do work, but they don't account for time spent already in the day (only counts it since it first was scheduled? - but just guessing). This seems to be the change in behavior that is making it seem like broken. I have an app that uses individual FamilyControls / Screen Time authorization. I am still investigating but reporting ASAP. Will add feedback and more later. I am not sure what's going on, but so far: App limits generally work fine throughout the day(?) At around 9 PM they stop working if I clear ManagedSettingStore/DeviceActivityCenter (it might be unrelated to the time, but just clearing, but this is just what I know so far) I tried setting app limits from Apple's Setting app (so I could see if it's not just my app, and that system could have issues) and it crashes. The whole Settings app freezes and then crashes. (edit: after some freezing, including in the app picker, I was able to set a limit and it worked...did notice some odd behavior where 1 minute break did not work, but selecting 15 minute break did work) going to also update: FB13688616
Posted
by kgaidis.
Last updated
.
Post not yet marked as solved
0 Replies
145 Views
Hello, I am working on a screen time manager that can block certain apps. I want this to work by allowing a certain number of 5-minute sessions per day. For each app the user selects, I would like to store the number of sessions remaining for that app in a dictionary. Currently, I am storing them in a dictionary of type <AppToken: Int>. However, I would like to store this dictionary to UserDefaults, and it doesn't seem like it is possible to store the type AppToken to UserDefaults. I was wondering how I could go about storing the AppTokenas a String and maybe saving to UserDefaults as a <String: Int> instead? Thanks.
Posted Last updated
.
Post not yet marked as solved
5 Replies
654 Views
I've heard family controls request forms can take up to weeks and even months... I'm currently developing an app that requires the main target and also the app extension to both use Family Controls. Does this mean I need to request forms for both app bundles separately or just the main app? If I have to wait weeks or even months for both then that's a bit painful tbh. Is there a way to distribute to testflight without getting approved for the family controls entitlement? Thanks
Posted Last updated
.
Post not yet marked as solved
0 Replies
172 Views
I am currently debugging an issue with DeviceActivityMonitor where the threshold is reached even though the target app (e.g. Instagram) is not being used actively. I noticed that the device with the unexpected behavior had the instagram.com website opened in the Safari web browser (among hundreds of other tabs). That tab was not actively used either (not in foreground, Safari app neither used). However, I was wondering if it can happen that this website is contributing towards the threshold as well even though it is in background and not used? Otherwise I cannot explain myself this strange behavior.
Posted
by Quappi.
Last updated
.