Family Controls

RSS for tag

Prevent access to the Screen Time API without guardian approval and provide opaque tokens that represent apps and websites.

Posts under Family Controls tag

194 Posts

Post

Replies

Boosts

Views

Activity

Screen Time API - Device Activity Report
I need some assistance with the Screen Time API’s DeviceActivityReport extension. I know the extension is sandboxed but I need the data inside my app. Jomo is currently doing this so it’s not impossible. I see they’re saying it’s an estimate which is about 5 - 10 off of the actual screen time, but how are they doing this? Any attempt to store the screen time data inside some sort of database or UserDefaults always fails of course due to the sandbox. Any advice would be greatly appreciated!
0
0
460
Oct ’24
Difficulty blocking and scheduling with the Screen Time API
Hello, I'm currently facing some technical difficulties in implementing features related to application restrictions using the ScreenTime API. In our app, we allow users to set up restrictions for specific apps and app categories, with scheduled times and days (for example, Mondays and Thursdays, from 2pm to 5pm). The blocking sessions must run independently and simultaneously, allowing different sets of applications to be restricted at different times. However, I ran into two main problems: 1. Applying restrictions in the DeviceActivityMonitor extension: Although I can enable and disable restrictions, I haven't found an effective way to apply multiple FamilyActivitySelections directly in the DeviceActivityMonitor extension. The extension has to manage different blocking sessions independently, restricting different sets of applications and categories simultaneously or separately. I would like to know if it is possible to transmit this list of selected applications via UserDefaults or CoreData to the extension in order to facilitate this integra To better illustrate, here is a snippet of the code I am using: import Foundation import FamilyControls import ManagedSettings import DeviceActivity class AppBlockManager: ObservableObject { private let store = ManagedSettingsStore() private let center = DeviceActivityCenter() @Published var activitySelection: FamilyActivitySelection private var activityName: DeviceActivityName private var schedule: DeviceActivitySchedule init(selection: FamilyActivitySelection, activityName: DeviceActivityName, schedule: DeviceActivitySchedule) { self.activitySelection = selection self.activityName = activityName self.schedule = schedule } func startBlock() { do { try center.startMonitoring(activityName, during: schedule) if let applications = activitySelection.applications.isEmpty ? nil : activitySelection.applicationTokens { store.shield.applications = applications } if let categories = activitySelection.categories.isEmpty ? nil : activitySelection.categoryTokens { store.shield.applicationCategories = ShieldSettings .ActivityCategoryPolicy .specific(categories) store.shield.webDomainCategories = ShieldSettings .ActivityCategoryPolicy .specific(categories) } if let webDomains = activitySelection.webDomains.isEmpty ? nil : activitySelection.webDomainTokens { store.shield.webDomains = webDomains } } catch { print("Error starting monitoring: \(error)") } } func stopBlock() { store.shield.applications = nil store.shield.webDomains = nil store.shield.applicationCategories = nil store.shield.webDomainCategories = nil center.stopMonitoring([activityName]) } } Currently, this AppBlockManager is part of the main app target, not within the DeviceActivityMonitor extension, which is currently empty. With this configuration, I can only have one blocking session active at a time, and when it is deactivated, all restrictions are removed. I tried using different ManagedSettingsStore instances, each named individually, but without success. 2. Problems with scheduling restrictions: Currently, when setting up scheduled monitoring via DeviceActivitySchedule, the restrictions are activated immediately, ignoring the specific times scheduled (e.g. starting at 2pm and ending at 5pm). I need the schedule to work correctly, applying the restrictions only during the defined periods. Alternatively, I've considered running a background task that checks whether active sessions (up to a maximum of 3) should apply the restrictions at that time, but I'm still looking for a more suitable solution. In view of these challenges, I would like some guidance on the following points: What would be the best way to configure the DeviceActivityMonitor extension to receive and apply different FamilyActivitySelections, ensuring that the blocking sessions are independent and can run simultaneously? Is there a recommended approach to ensure that restrictions scheduled via DeviceActivitySchedule are applied and removed according to the times and days defined by the user, ensuring that applications are restricted only during the scheduled periods?
2
2
854
Oct ’24
Family Activity Picker crashes (Connection to plugin invalidated while in use)
Even on iOS 18 (16-17 also repo) we are seeing a crash on the FamilyActivityPicker when users tap on "Other" or just at random times. We see the follow debug message but no other way of identifying the issue in code. [u 3C8AF272-DC4E-55C4-B8C6-34826D2BEB5B:m (null)] [com.apple.FamilyControls.ActivityPickerExtension(1150.1)] Connection to plugin invalidated while in use. Even with the most basic implementation of FamilyActivityPicker (example below) we can repro this crash consistently. Big applications (think Opal) see the same issue but it seems like they see it less, and are able to intercept the disconnect in order to show an error to the user. My two questions are How can we intercept this crash/disconnect in order to alert our user and restart the experience? Is this EVER gonna get fixed properly? Usage Example: var body: some View { NavigationView { ZStack { familyPickerErrorView .opacity(isHidden ? 0 : 1) .onAppear { DispatchQueue.main.asyncAfter(deadline: .now() + 2) { withAnimation { isHidden = false } } } VStack { Color.clear .frame(height: 1) .background(Color(UIColor.systemBackground)) FamilyActivityPicker( headerText: "Select Apps To Be Blocked (Maximum of 50)", footerText: "Want to block Safari? Check our FAQs", selection: $familySelection) .ignoresSafeArea(.all) } } } .toolbar { ToolbarItem(placement: .navigationBarLeading) { Button(action: { isPresented = false }) { Text("Cancel") .foregroundColor(.black) } } ToolbarItem(placement: .navigationBarTrailing) { Button(action: { isPresented = false }) { Text("Done") } } } .navigationBarTitleDisplayMode(.inline) .alert(isPresented: $showAlert) { Alert(title: Text("Family Activity Picker Issue"), message: Text(alertMessage), dismissButton: .default(Text("OK"))) } .onAppear { isPresented = true } }
1
0
617
Oct ’24
Bug in DeviceActivity
I am developing an app using DeviceActivity. let schedule = DeviceActivitySchedule( intervalStart: DateComponents(hour : 0, minute : 0, second: 1), intervalEnd: DateComponents(hour : 23, minute : 59, second: 59), repeats: true ) I found that on the second day, intervalDidStart(for: DeviceActivityName) gets called multiple times. I also tried let schedule = DeviceActivitySchedule( intervalStart: DateComponents(hour : 0, minute : 0, second: 1), intervalEnd: DateComponents(hour : 23, minute : 59, second: 59), repeats: false ) and started monitoring for the next day in the intervalDidEnd(for: DeviceActivityName) method. but , intervalDidStart(for: DeviceActivityName) still gets called multiple times. How should I resolve this issue?
0
0
426
Oct ’24
iOS 18 fixed the problem with screen time and family share
But only until the update to iOS 18.0.1 came along just a few weeks later. EVERY TIME there's an update it breaks family share and screen time. EVERY TIME single time! And to fix, you must have the kid's phone in hand (easier for parents with little kids, not so easy with teens, also not easy for kids whose parents are split up and kid spends one week with you and one week with other parent). Then you have to make sure they are both on the same iOS version, then you have to log into iCloud and set up family sharing all over again. THIS SUCKS. Apple you can do better.
1
0
857
Oct ’24
Requesting support for Bugs related to ScreenTime API
Hello Apple Developer Community, We're developing a parental control app using Apple's ScreenTime API and Family Sharing capabilities. We've encountered several persistent issues that are affecting our users' experience. We've found similar reports from other developers, suggesting these might be widespread problems. We're hoping to get some insight or solutions from the community or Apple experts. Issues we're facing: Parent apps visible on child's device: After granting Family Sharing permission on the family picker, sometimes the parent's apps are visible instead of the child's apps. Related issue: https://forums.developer.apple.com/forums/thread/749672 Inconsistent app visibility on family picker:* The behaviour of the family picker is unpredictable: Sometimes, no apps are visible at all, only categories. Other times, categories are displayed and upon selection, enforcement works correctly. In some instances, the stream delivering updates to the selection from the app extension doesn't send anything. Related issue: https://forums.developer.apple.com/forums/thread/729198 Rules not enforced with different OS versions: When the parent and child devices are running different iOS versions (both above iOS 16), ScreenTime rules don't seem to work correctly. General inconsistencies: We've observed various other inconsistencies in the behavior of the ScreenTime API. These issues are less predictable but contribute to an overall unreliable user experience. Steps to Reproduce: Add a child device using a parental control app (in our case, Adora for Kids). Grant the Family Sharing permission. Open the family picker to set up ScreenTime rules. Observe the inconsistent behaviour: a. Sometimes no apps are visible. b. Sometimes only categories are visible. c. Sometimes both categories and apps are visible. When categories are visible, select a category and attempt to enforce a rule. Enforce a ScreenTime rule. Ensure the parent and child devices are running different iOS versions (both iOS 16+). Test various ScreenTime rules and observe their enforcement across different device configurations. Questions: Are these known issues with the ScreenTime API? What could be causing the inconsistent behavior in the family picker and the stream of updates from the app extension? Are there any workarounds or best practices to mitigate these problems? Is there any additional information we can provide to help investigate these issues? Are there any plans to improve the stability and consistency of the ScreenTime API in future iOS releases? We've tried researching these issues through various channels, including Apple's documentation and community forums, but haven't found definitive solutions. Any insights or assistance would be greatly appreciated. Thank you for your time and help! Environment: Development: Xcode 15.4, macOS 14.2.1 Runtime: iOS 16+ App: Adora (App Store ID: 1671825554)
2
1
363
Oct ’24
DeviceActivityReport - Slow Synchronization. Screen time api, Family Controls
Hello! I am developing an app using the Screen Time API. Everything is good, but I have a problem with DeviceActivityReport. On the child’s device, stats are synced to the app in about 1-5 minutes. However, on the parent’s device, it can take around an hour or more. How can I make the stats sync faster between the child’s device and the parent’s device? How I Implemented It @Published var context: DeviceActivityReport.Context = .init("Time Limit") let filter = DeviceActivityFilter( segment: .daily( during: Calendar.current.dateInterval(of: .day, for: .now)! ), users: .children, devices: .all, applications: applicationTokens ) DeviceActivityReport(viewModel.context, filter: viewModel.filter) .frame(maxHeight: viewModel.maxReportHeight) In the Report Extension (Test Code) for await d in data { result += "device.name=\(d.device.name ?? "")" result += "\nuser.appleID=\(d.user.appleID ?? "")" result += "\ngivenName=\(d.user.nameComponents?.givenName ?? "")" result += "\nrole=\(d.user.role.rawValue)" for await activity in d.activitySegments { result += "\nactivitySegments hashValue=\(activity.hashValue)" result += "\ntotalActivityDuration=\(activity.totalActivityDuration)" result += "\ndateInterval=\(activity.dateInterval)" for await category in activity.categories { result += "\ncategory=\(category.category.localizedDisplayName ?? "")" for await app in category.applications { result += "\napp=\(app.application.bundleIdentifier ?? ""), time=\(app.totalActivityDuration)" } } } } Problems: activity.categories can be empty for a long time app.totalActivityDuration contains outdated information I need to wait about 1+ hours to get “actual” information.
1
0
491
Oct ’24
no response to request for family controls entitlement
About 5 weeks ago, I requested a Family Controls Entitlement using this form: https://developer.apple.com/contact/request/family-controls-distribution I have yet to hear anything back. About a week ago, I submitted a support request through my Apple developer account, asking about the entitlement, and have also not heard anything back. Is it normal to wait this long? Is there a way to check on the status of my request? Is there some other channel I should be using to ask for information about this process?
1
2
410
Oct ’24
Unable to Retrieve bundleIdentifier with FamilyControls .individual Authorization
Tl:dr What are some reasons my bundleIDs aren't showing up and does anyone have good resources to setup the screentime API/DeviceActivityMonitorExtension? I'm working on an iOS app that uses the FamilyControls and DeviceActivity frameworks to monitor and restrict app usage. The app allows users to select apps and set usage limits. When a limit is reached, a DeviceActivityMonitorExtension should block the selected apps. My App setup: Have a model that is called when users select apps to manage these app bundle IDs are then serialized and sent to the Device Monitor Extension via App Group so it can be used when the event threshold is reached. Cant use Application Tokens because they are not serielizable and cant be passed to the extension. Problem: While testing, I’m unable to retrieve the bundleIdentifier and localizedDisplayName from the Application objects after selecting apps. Instead, these properties are nil or empty, preventing me from saving the bundle IDs to share with the extension via App Groups. Assumptions: I suspect this issue is due to missing the com.apple.developer.screentime.api entitlement, which might be required to access these properties even during development. I've requested for the entitlement but its still under review. Key Code Snippets: Authorization Request: class ScreenTimeManager: ObservableObject { static let shared = ScreenTimeManager() @Published var isAuthorized: Bool = false func requestAuthorization() async { do { try await AuthorizationCenter.shared.requestAuthorization(for: .individual) DispatchQueue.main.async { self.isAuthorized = AuthorizationCenter.shared.authorizationStatus == .approved print("Authorization status: \(AuthorizationCenter.shared.authorizationStatus)") } } catch { DispatchQueue.main.async { print("Authorization failed: \(error.localizedDescription)") self.isAuthorized = false } } } } Accessing bundleIdentifier: print("addAppGroup() Called") let managedApps = selection.applications.compactMap { application -> ManagedApp? in guard let token = application.token else { print("No token for application: \(application)") return nil } let app = Application(token: token) print("New Application instance: \(app)") guard let bundleID = app.bundleIdentifier, !bundleID.isEmpty else { print("Bundle identifier is empty or nil for application: \(app)") return nil } let displayName = app.localizedName ?? "Unknown App" print("Processing application with bundleIdentifier: '\(bundleID)' and displayName: '\(displayName)'") return ManagedApp( bundleIdentifier: bundleID, applicationToken: token, localizedDisplayName: displayName ) } if managedApps.isEmpty { print("No managed apps created. Exiting addAppGroup().") return } // Continue with creating DeviceActivityEvent... } Logs - Shows application token but never bundleID or LocalizedDisplayname Application(bundleIdentifer: nil, token: Optional(128 byte <TOKEN_PRESENT>), localizedDisplayName: nil) What I've Tried: Ensured Screen Time is enabled on the device. Verified App Group configuration in both app and extension. Checked that authorization is being requested and the status is .approved. Cleaned and rebuilt the project. Questions: Is the com.apple.developer.screentime.api entitlement required to access bundleIdentifier and localizedDisplayName when using .individual authorization? Is there a way to access these properties without the entitlement, or am I missing a configuration step? Has anyone faced a similar issue and found a solution? Lastly, is there a good place for additional resources on the screentime API??
1
0
654
Sep ’24
Shielding .all(except: ) unexpected behavior
Hi everyone, I’m encountering an issue with shield.applicationCategories = .all(except: applications.applicationTokens) when trying to shield all apps except a specified few. Despite using this configuration, all apps are getting shielded, including those that should be exempt. I’ve verified that the correct applicationTokens are being used and ensured that there are no conflicting schedules that might override this configuration. Interestingly, the ShieldConfiguration appears for the apps that are supposed to be blocked, but not for the ones in the exception list. Has anyone else experienced this issue, or does anyone have insights into what might be causing this behavior? Thanks in advance!
2
1
1k
Sep ’24
Family Controls Capabilities missing from capabilities menu in XCode
I am developing an app that will utilize the Family Controls capability to use the DeviceActivity API. I understand that I need to request access to the Family Controls entitlement before releasing the app, but I am nowhere near that stage. I want to be able to test the Family Controls/Device Activity APIs while developing the app in debug mode, but I don't have the ability to add the Family Controls capability to my app. When I go to add it, it doesn't show up in the available options of capabilities to add. Do I need authorization for the Family Controls entitlement to even use the APIs in testing/development? Am I missing a prerequisite checkbox somewhere that would add the capability to the available options? I'm using XCode 16.0.
1
0
864
Sep ’24
Extra Consent Needed for IAPs if Family Sharing is Disabled?
Hi everyone, I’m developing an game with in-app purchases, designed for a a mixed audience(could be used by kids under 13). I understand that Apple’s Family Sharing has built-in consent mechanisms, like “Ask to Buy,” which helps manage purchases for kids. However, I’m unsure how to handle cases where Family Sharing is not set up or is disabled. Key Concerns: Kids Without Family Sharing: It’s possible for kids to have Apple IDs that are not part of Family Sharing, either because the feature is disabled, set up incorrectly, or the child is using an independent account due to an incorrect birthdate. This raises questions about whether relying solely on Apple’s built-in protections is sufficient. Is It Enough to Rely on Apple’s Systems?: Apple’s systems do a great job of managing consent when Family Sharing is in place, but I’m concerned about compliance in cases where kids are not covered by these protections. I want to ensure that my app remains compliant with COPPA and other relevant regulations, especially for users not covered by Family Sharing, without adding unnecessary layers for those who are correctly set up. Looking forward to your insights and recommendations! Thanks in advance!
0
0
375
Sep ’24