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

132 Posts

Post

Replies

Boosts

Views

Activity

DeviceActivityReport view fails to render until it's repeatedly added to the view hierarchy
The DeviceActivityReport view does not render immediately when added to the view hierarchy. Instead, it requires repeated navigation to the screen hosting the DeviceActivityReport view for it to appear. Furthermore, there is no programmatic way to determine whether the view is being rendered for the user, leading to an inconsistent and often poor user experience. I've created a sample project that demonstrates the issue.
2
1
405
Mar ’25
Guidance on Upgrading to Production Access for Screen Time API
Hello everyone, I’m currently developing an app that uses the Family Controls API, specifically the Screen Time API. However, my current entitlement is limited to development mode, which prevents me from publishing my app on TestFlight. I have already contacted Apple Developer Support for production access but wanted to reach out to the community as well and I was referenced to FamilyControls API documentation and I couldn't find anything related to my case. Has anyone successfully upgraded their entitlement from development-only to production? Any insights on the process, tips for communicating with Developer Support, or guidance on ensuring full compliance with the Family Controls guidelines would be extremely helpful.
0
0
271
Mar ’25
macOS app can be excluded from the ‘Screen Time’ statistics?
I am a macOS software developer using Xcode and Objective-C. I have a wallpaper app on the App Store, and recently, a few users have asked if the app can be excluded from the ‘Screen Time’ statistics. Is there a way to allow users to choose whether or not the app should appear in the ‘Screen Time’ tracking? I have already set LSUIElement to YES in the info.plist, but the app is still being tracked in ‘Screen Time.
0
0
156
Feb ’25
Unblocking Apps After a Scheduled Duration in FamilyControl
I am able to block apps using FamilyControl and Shield. Unblocking is also simple—just assign nil to store.shield.applications. However, I want to unblock them even when the app is not open. Use case: Let's say the app allows users to create a session where a particular app is blocked for a specific duration. Once the session starts, the app should remain blocked, and as soon as the session time ends, it should automatically be unblocked. Please help me with this. Thank you!
0
0
370
Feb ’25
Pre-approval for Family Controls Entitlement?
Hi there, I am planning an app that requires use of the Family Controls Entitlement to access data on the user's screen time. I understand that this has to be requested from Apple before it can be used in production. I have found the following form to request approval, but it requires an App and bundle ID, which suggests that approval can only be requested after the app has been developed. https://developer.apple.com/contact/request/family-controls-distribution I'd like to avoid the situation where I spend a lot of time on developing the app, only to find out that the Family Controls Entitlement will not be granted for my use case. Is there any way that I can request provisional pre-approval for my app? Perhaps based on an app description and some mockups? Or, at least some idea of whether my particular use case is likely to be approved? Thanks.
1
0
406
Feb ’25
Related WebDomain Token is automatically blocked, but how do we know the related ManagedSettingsStore?
I have noticed that when I select the app token of the youtube app to be blocked via a ManagedSettingsStore, the youtube website is blocked as well (which is a good and intended behavior IMO). But how do I know in the ShieldConfigurationDataSource’s override func configuration(shielding webDomain: WebDomain, in category: ActivityCategory) -> ShieldConfiguration to which ManagedSettingsStore the WebDomain’s token is related? We use different ManagedSettingsStores for different block purposes, which differentiate in their ShieldConfiguration. Thanks a lot and have a great day!
2
0
449
Feb ’25
Detect change to apps Screen Time Access
I'm creating an app which gamifies Screen Time reduction. I'm running into an issue with apples Screen Time setting where the user can disable my apps "Screen Time access" and get around losing the game. Is there a way to detect when this setting is disabled for my app? I've tried using AuthorizationCenter.shared.authorizationStatus but this didn't do the trick. Does anyone have an ideas?
0
0
360
Feb ’25
DeviceActivityMonitor.intervalDidEnd never getting called
I'm trying to build an app with a DeviceActivityMonitor extension that executes some code after 15 minutes. I can confirm that the extension is set up correctly and that intervalDidStart is executed, but for some reason the intervalDidEnd method never gets called. What I'm doing in both is just registering a local notification. class DeviceActivityMonitorExtension: DeviceActivityMonitor { let store = ManagedSettingsStore() override func intervalDidStart(for activity: DeviceActivityName) { createPushNotification( title: "Session activated!", body: "" ) super.intervalDidStart(for: activity) } override func intervalDidEnd(for activity: DeviceActivityName) { createPushNotification( title: "Session ended", body: "" ) super.intervalDidEnd(for: activity) } private func createPushNotification(title: String, body: String) { let content = UNMutableNotificationContent() content.title = title content.body = body // Configure the recurring date. var dateComponents = Calendar.current.dateComponents([.era, .year, .month, .day, .hour, .minute, .second], from: Date().addingTimeInterval(1.0)) dateComponents.calendar = Calendar.current dateComponents.timeZone = TimeZone.current // Create the trigger as a repeating event. let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false) let uuidString = UUID().uuidString let request = UNNotificationRequest(identifier: uuidString, content: content, trigger: trigger) // Schedule the request with the system. let notificationCenter = UNUserNotificationCenter.current() notificationCenter.add(request) } } And this is the method that is starting the monitoring session: @objc public static func startSession() -> String? { // Calculate start and end times let center = DeviceActivityCenter() let minutes = 15 let startDate = Date().addingTimeInterval(1) guard let endDate = Calendar.current.date(byAdding: .minute, value: minutes, to: startDate) else { return "Failed to create end date?" } // Create date components and explicitly set the calendar and timeZone let startComponents = Calendar.current.dateComponents([.era, .year, .month, .day, .hour, .minute, .second], from: startDate) let endComponents = Calendar.current.dateComponents([.era, .year, .month, .day, .hour, .minute, .second], from: endDate) // Create schedule let schedule = DeviceActivitySchedule( intervalStart: startComponents, intervalEnd: endComponents, repeats: false ) print("Now", Date()) print("Start", startDate, startComponents) print("End", endDate, endComponents) print(schedule.nextInterval) do { // Use a consistent activity name for our simple implementation let activity = DeviceActivityName("SimpleSession") try center.startMonitoring(activity, during: schedule) return nil } catch { return "Failed to start monitoring: \(error)" } } I can confirm my dates & date components make sense with the 4 print statements. Here is the output: Now 2025-02-12 04:21:32 +0000 Start 2025-02-12 04:21:33 +0000 era: 1 year: 2025 month: 2 day: 11 hour: 20 minute: 21 second: 33 isLeapMonth: false End 2025-02-12 04:36:33 +0000 era: 1 year: 2025 month: 2 day: 11 hour: 20 minute: 36 second: 33 isLeapMonth: false Optional(2025-02-12 04:21:33 +0000 to 2025-02-12 04:36:33 +0000) I get the Session activated! notification but never get the Session ended notification. Half an hour later, I've tried debugging the DeviceActivityCenter by printing out the activities property and can see that it is still there. When I try to print out the nextInterval property on the schedule object i get from calling center.schedule(for:), it returns nil. I'm running this on an iPhone 8 testing device with developer mode enabled. It has iOS 16.7.10. I'm totally lost as to how to get this to work.
1
0
346
Feb ’25
Device Activity Report only for Selected Apps
I want to display device activity reports for particular selected apps. for getting a daily basis app uses time. Now, what is happening? there are 10 apps selected from the family activity picker but some apps are displayed in the list. I need all 10 apps or more that I will choose from the family activity picker. The bellow code is used for fetching reports. var body: some View { VStack { DeviceActivityReport(context, filter: filter) } } bellow code is used for the filter @State public var filter = DeviceActivityFilter() init(selectedApps: Set<ApplicationToken>, selectedCategories: Set<ActivityCategoryToken>, selectedWebDomains: Set<WebDomainToken>) { self.selectedApps = selectedApps self.selectedCategories = selectedCategories self.selectedWebDomains = selectedWebDomains self.filter = DeviceActivityFilter( segment: .daily( during: Calendar.current.dateInterval( of: .weekOfYear, for: .now )! ), users: .all, devices: .init([.iPhone]), applications: selectedApps, categories: selectedCategories, webDomains: selectedWebDomains ) } You can see we selected 3 apps from family activity picker but we getting 2 apps from DeviceActivityReport extension following code is for device activity report extension let context: DeviceActivityReport.Context = .totalActivity // Define the custom configuration and the resulting view for this report. let content: (ActivityReport) -> TotalActivityView func makeConfiguration(representing data: DeviceActivityResults<DeviceActivityData>) async -> ActivityReport { // Reformat the data into a configuration that can be used to create // the report's view. var res = "" var list: [AppDeviceActivity] = [] let totalActivityDuration = await data.flatMap { $0.activitySegments }.reduce(0, { $0 + $1.totalActivityDuration }) for await d in data { res += d.user.appleID!.debugDescription res += d.lastUpdatedDate.description for await a in d.activitySegments{ res += a.totalActivityDuration.formatted() for await c in a.categories { for await ap in c.applications { if let apptoken = ap.application.token { let appName = (ap.application.localizedDisplayName ?? "nil") let bundle = (ap.application.bundleIdentifier ?? "nil") let duration = ap.totalActivityDuration let numberOfPickups = ap.numberOfPickups let app = AppDeviceActivity(appToken: apptoken, id: bundle, displayName: appName, duration: duration, numberOfPickups: numberOfPickups) list.append(app) } } } } } return ActivityReport(totalDuration: totalActivityDuration, apps: list) }
4
0
961
Feb ’25
Any workaround for expanding a large category in FamilyActivityPicker?
I’m developing a self-management app using Family Controls, but I’ve encountered a FamilyActivityPciker's crash due to an XPC(or UIRemoteView) issue when there are too many tokens(maybe 200+ items) in a category. This makes bad UX, so I’m looking for a workaround. (I guess that the crash reason is cross process memory limitations, such as App Extension 50MB memory limitation.) A lot of web domains contribute to increase the number of tokens, However, even after clearing Safari’s browsing history, the tokens displayed in the FamilyActivityPicker remains unchanged. Is there any workaround that a 3rd party developer can implement to address this issue? prevent FamilyActivityPicker crashes or reduce the number of web domain tokens? For example, if there’s a way to reset the web domain tokens shown in FamilyActivityPicker from the Settings app, I could offer a help to users. Does anybody have ideas? Expanding SNS Category (29 items) It succeeded. Expanding Productivity & Finance (214 items) It failed. The screen froze, then appears blank. When the number of items is around 100, the crash rate is 50%, but when the items are over 200, the crash rate is 100%. Search Bar Problem The search bar also has same problem. If the number of search results are small, it works good without any blank, but if there are a lot of search results (200+), the XCP crashes and the screen appears blank. Code to Reproduce import SwiftUI import FamilyControls struct ContentView: View { @State private var selection = FamilyActivitySelection() @State private var isPickerPresented: Bool = false var body: some View { VStack { Button("Open Picker") { isPickerPresented = true } } .familyActivityPicker(isPresented: $isPickerPresented, selection: $selection) } } Steps to Reproduce Prepare a category that has 200+ items Try to open the category in the picker The screen will freeze, then appears blank. Errors in Console [u EDD60B83-5D2A-5446-B2C7-57D47C937916:m (null)] [com.apple.FamilyControls.ActivityPickerExtension(1204)] Connection to plugin interrupted while in use. AX Lookup problem - errorCode:1100 error:Permission denied portName:'com.apple.iphone.axserver' PID:2164 ( 0 AXRuntime 0x00000001d46c5f08 _AXGetPortFromCache + 796 1 AXRuntime 0x00000001d46ca23c AXUIElementPerformFencedActionWithValue + 700 2 UIKit 0x0000000256b75cec C01ACC79-A5BA-3017-91BD-A03759576BBF + 1527020 3 libdispatch.dylib 0x000000010546ca30 _dispatch_call_block_and_release + 32 4 libdispatch.dylib 0x000000010546e71c _dispatch_client_callout + 20 5 libdispatch.dylib 0x00000001054765e8 _dispatch_lane_serial_drain + 828 6 libdispatch.dylib 0x0000000105477360 _dispatch_lane_invoke + 408 7 libdispatch.dylib 0x00000001054845f0 _dispatch_root_queue_drain_deferred_wlh + 328 8 libdispatch.dylib 0x0000000105483c00 _dispatch_workloop_worker_thread + 580 9 libsystem_pthread.dylib 0x0000000224f77c7c _pthread_wqthread + 288 10 libsystem_pthread.dylib 0x0000000224f74488 start_wqthread + 8 ) Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}>
7
4
2.1k
Feb ’25
Open parent app from ShieldAction extension in iOS
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()     }   }   }
10
7
5.0k
Jan ’25
Screen Time issues after transferring App developer account ownership
After transferring the App ownership to a different account, if you update the app on iOS, two identical apps will show up in Settings > Screen Time. Users can't control the blocking settings from before the update - the only fix is to restart the phone. After the next execution of manageStore.shield.applications, users still can't manually disable the restrictions - their only option is to uninstall and reinstall the app. I believe this is related to how Screen Time API's authentication works - it's not just tied to the app's bundle ID, but also linked to the developer account's organization ID. Any suggestions for a clean solution that would allow smooth app updates after the transfer without running into these issues?
2
0
413
Jan ’25
Provisioning Profile Error
I'm building an app that uses the Screen Time API and DeviceActivityMonitoring Framework. It works when I run the simulator build on iPhone 16 but when I try to launch it on my own iPhone, I get these errors. Provisioning profile "iOS Team Provisioning Profile: Kanso- Digital-Wellness.Kanso-v2" doesn't include the com.apple.developer.device-activity.monitoring entitlement. KansoMonitorExtension 1 issue x Provisioning profile "iOS Team Provisioning Profile: Kanso-Digital-Wellness.Kanso-v2.KansoMonitorExtension" doesn't include the com.apple.developer.device-activity.monitoring en... Read something online that said a reboot would fix this, but I tried and no luck. Any ideas? I'm not very technical, so would pay someone to fix this for me :)
1
0
495
Jan ’25
How do I persist the Family Activity Picker?
I am currently building a screen time app and I am trying to figure out how to persist the family activity picker so that when my app closes and re-opens, the app selections in it are saved. I've successfully implemented core data and figured out how to store names of the selected apps in a list like this - Core Data addApp Function - func addApp(name: String, context: NSManagedObjectContext){ let newApp = AppToken(context: context) newApp.bundleIdentifier = name saveData(context: context) } Adding app selections to Core Data (after the family activity picker has updated the selection) - .onChange(of: model.selectionToDiscourage) { for i in model.selectionToDiscourage.applications { print(i) dataController.addApp(name:i.localizedDisplayName ?? "Temp", context: moc) } Printing saved selections in a list (bundleIdentifier is my attribute for my appToken entity, but I am just pulling the names here. For whatever reason all of them end up being Temp" as shown above anyway. In other words name:i.localizedDisplayName is not working and Temp is shown in the list for every app chosen) - if dataController.savedSelection.isEmpty { Text("No Apps Selected") .foregroundColor(.gray) } else { List(dataController.savedSelection, id: \.self) { app in Text(app.bundleIdentifier ?? "Unknown App") } .scrollContentBackground(.hidden) } So, when my app closes and reopens, the list of app names persists. Now, my issue is figuring out how to write back to selectionToDiscourage and loading the family activity picker with those saved apps. I have no idea if I should be doing this a different way and if using Core Data is overkill, but I cannot figure out how it's syntactically possible to write back to this family activity picker when the app reopens - .familyActivityPicker(isPresented: $isPresented, selection:$model.selectionToDiscourage) Thank you to whoever takes a look at this!!
6
0
1.2k
Jan ’25
Problem with DeviceActivitySchedule and DeviceActivityMonitor
Hey, I’m having some issues with DeviceActivitySchedule and DeviceActivityMonitor. I want to create a schedule that blocks apps (by family control) when it starts. However, even when the schedule is supposed to start on this iPhone, nothing happens, and no logs are being recorded main target: // TestView_.swift // Sloth // // Created by on 11/01/2025. // import SwiftUI import DeviceActivity import FamilyControls import ManagedSettings struct TestView_: View { var body: some View { VStack(spacing: 20) { Text("Test DeviceActivityMonitor") .font(.title) Button("Start test mon") { let now = Date() let start = Calendar.current.date(byAdding: .minute, value: 2, to: now)! let end = Calendar.current.date(byAdding: .minute, value: 20, to: now)! print("thd") DeviceScheduleTester().scheduleTestActivity(startDate: start, endDate: end) } } .padding() } } extension DeviceActivityName { static let daily = DeviceActivityName("daily") } DeviceActivityMonitor: class DeviceScheduleTester { private let center = DeviceActivityCenter() func scheduleTestActivity(startDate: Date, endDate: Date) { let calendar = Calendar.current let startComponents = calendar.dateComponents([.hour, .minute], from: startDate) let endComponents = calendar.dateComponents([.hour, .minute], from: endDate) // Tworzymy schedule let schedule = DeviceActivitySchedule( intervalStart: startComponents, intervalEnd: endComponents, repeats: true ) do { try center.startMonitoring(.daily, during:schedule) print("startMonit /(\(schedule))") } catch { print("ghfgh") } } } struct TestView__Previews: PreviewProvider { static var previews: some View { TestView_() } } DeviceActivityMonitor target: // BlockingAppsMonitorExtension // // Created by on 10/01/2025. import DeviceActivity import FamilyControls import ManagedSettings import os let logger = Logger() public class BlockingAppsMonitor: DeviceActivityMonitor { private let store = ManagedSettingsStore() public override func intervalDidStart(for activity: DeviceActivityName) { super.intervalDidStart(for: activity) print("Rozpoczęcie interwału blokowania \(activity.rawValue)") logger.info("intervalDidStart") startBlocking() } public override func intervalDidEnd(for activity: DeviceActivityName) { super.intervalDidEnd(for: activity) print("Zakończenie interwału blokowania \(activity.rawValue)") logger.info("intervalDidend") stopBlocking() } @discardableResult private func startBlocking() -&gt; Int { print("number of unique apps") return 51 store.shield.applicationCategories = .all() // return exceptions.count } private func stopBlocking() { store.shield.applicationCategories = nil store.shield.applications = nil } } INB4: In both files are added family controls Secent file is added in DeviceActivityMonitor target. Apple answer please?
1
0
492
Jan ’25
My App have Incorrect name and icon displayed in Screen Time
STEPS TO REPRODUCE Install the application “Dynamic-Lyrics" develop by me, which the bundle ID is com.bing.lyrics (https://apps.apple.com/us/app/id6476125287) Use this APP for a period of time Go to Settings - Screen Time - See All App & Website Activity I found that the name and icon displayed in Screen Time are incorrect. The expectation is: “Dynamic-Lyrics", but the actual display is "com.microsoft.bing" The guess is that the bundle ID contains the characters com.bing (bing is my name) and is incorrectly recognized as microsoft’s app.
1
0
358
Jan ’25
DeviceActivityReportExtension / ScreenTimeBriefReport does not localize strings
Hello, In one of our apps we use DeviceActivityReportExtension to show the user how much screen time is remaining. The calculation is working as expected, but we have noticed that the labels in our ScreenTimeBriefReport are not localized to the device language. Example: Device with language set to Swedish App fully translated to English and Swedish Result: All labels in app are using the Swedish translations, except the strings in our ScreenTimeBriefReport instance. These labels are using the English localization. I've verified it's using the English localization from our Localizable.xcstrings file. I tried logging device language from our ScreenTimeBriefReport instance, but I could not see anything in Console.app. I guess this is intentional so no sensitive user information can be extracted. Is this a known feature or bug? If it's the latter, is there a known workaround? Sincerely, César
1
0
525
Jan ’25
ShieldActionExtention not calling code or printing to console
I'm using ShieldActionExtention to make a HTTP request to a server when a user selects one of the buttons on their app shield. The apps are shielded, but nothing happens when I press one of the shield buttons. There is no message on the server signaling an HTTP request and nothing is printed to the XCode console while in debug mode. Here is my code for my Shield Action Extention // ShieldActionExtension.swift // ShieldAction // // import Foundation import UIKit import SwiftUI import ManagedSettings // Override the functions below to customize the shield actions used in various situations. // The system provides a default response for any functions that your subclass doesn't override. // Make sure that your class name matches the NSExtensionPrincipalClass in your Info.plist. class ShieldActionExtension: ShieldActionDelegate { override func handle(action: ShieldAction, for application: ApplicationToken, completionHandler: @escaping (ShieldActionResponse) -> Void) { print(action) let deviceID = UserDefaults.standard.string(forKey: UserDefaultKeys.userID.rawValue)! Task{ do{ print("sending to server") try await PlayerLosesGame(playerID: deviceID) completionHandler(.close) } catch { print("error occured on the shield") completionHandler(.none) } } } override func handle(action: ShieldAction, for webDomain: WebDomainToken, completionHandler: @escaping (ShieldActionResponse) -> Void) { print(action) let deviceID = UserDefaults.standard.string(forKey: UserDefaultKeys.userID.rawValue)! Task{ do{ print("sending to server") try await PlayerLosesGame(playerID: deviceID) completionHandler(.close) } catch { print("error occured on the shield") completionHandler(.none) } } } override func handle(action: ShieldAction, for category: ActivityCategoryToken, completionHandler: @escaping (ShieldActionResponse) -> Void) { print(action) let deviceID = UserDefaults.standard.string(forKey: UserDefaultKeys.userID.rawValue)! Task{ do{ print("sending to server") try await PlayerLosesGame(playerID: deviceID) completionHandler(.close) } catch { print("error occured on the shield") completionHandler(.none) } } //completionHandler(.close) } func PlayerLosesGame(playerID: String) async throws{ let url = URL(string: ServerConnection.GetWebsite() + "game/find?playerID="+playerID)! var request = URLRequest(url: url) request.httpMethod = "GET" print("trying this out") let (data, _) = try await URLSession.shared.data(for: request) } } I believe all my targets are set up correctly and should be working. Why is nothing happening?
2
0
549
Jan ’25