Hi everyone,
I’m experimenting with the new ScreenTime DeviceActivityReport view in SwiftUI (iOS 17 / Xcode 15).
My goal is to show the report inside a Button (or, more generally, capture any tap on it) so that I can push a detail screen when the user selects it.
Here’s the minimal code that reproduces the issue:
import FamilyControls
import DeviceActivity
import SwiftUI
struct ScreenTimeView: View {
let center = AuthorizationCenter.shared
@State private var context: DeviceActivityReport.Context =
.init(rawValue: "Total Activity")
@State private var filter = DeviceActivityFilter(
segment: .hourly(
during: Calendar.current.dateInterval(of: .day, for: .now)!
),
users: .all,
devices: .init([.iPhone, .iPad])
)
var body: some View {
ZStack {
DeviceActivityReport(context, filter: filter)
}
.onAppear {
Task {
do {
try await center.requestAuthorization(for: .individual)
} catch {
print("Authorization failed:", error)
}
}
}
}
}
struct ContentView: View {
var body: some View {
ScrollViewReader { _ in
ScrollView(showsIndicators: false) {
VStack {
Button {
print("BUTTON TAPPED") // ← never fires
} label: {
ScreenTimeView()
.frame(height: UIScreen.main.bounds.height * 1.4)
}
}
}
}
}
}
**
What happens**
DeviceActivityReport renders correctly with hourly bars.
Tapping anywhere inside the Button does not trigger print("BUTTON TAPPED").
I’ve tried replacing Button with .onTapGesture, adding .contentShape(Rectangle()), and .allowsHitTesting(true), but nothing registers.
What I’ve checked
Authorisation succeeds—calling code in .onAppear prints no errors.
Removing DeviceActivityReport and replacing it with a plain Rectangle() lets the tap gesture fire, so the issue seems specific to DeviceActivityReport.
Prevent access to the Screen Time API without guardian approval and provide opaque tokens that represent apps and websites.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have filled the form to request for this access, but it has been 15 days now and I haven’t gotten any feedback. Apple Support said the appropriate team will be in contact with me once it has been approved. It’s been 15 days and still nothing. I just want to know how long it would take, and Apple’s WWDC 2025 is around the corner, I was really looking forward to get this done before then.
Topic:
Developer Tools & Services
SubTopic:
Apple Developer Program
Tags:
Developer Tools
Entitlements
Family Controls
Hi,
I am developing a Screen Time App and I am having issues with the ShieldConfigurationExtension (ShieldConfigurationDataSource). I know this extensions is sandboxed but I should be able to read data from the main app.
I am using SwiftData as my database, but I am unable to initialize it in the extensions with an error indicating insufficient file permissions. I have App Group set up and I am able to share data using UserDefaults but that is just inconvenient.
Is there any way I could just open the SwiftData in read only mode so that I could display the user some info on the shield?
SwiftData Init:
private func setupContainer() throws {
let schema = Schema([
DogEntity.self,
HouseEntity.self
])
// Use app group container if available
let config: ModelConfiguration
if let containerURL = FileManager.default.containerURL(
forSecurityApplicationGroupIdentifier: "group.\(Bundle.app.bundleIdentifier ?? "")"
) {
config = ModelConfiguration(schema: schema, url: containerURL.appendingPathComponent("default.sqlite"))
} else {
config = ModelConfiguration(schema: schema)
}
self.container = try ModelContainer(for: schema, configurations: [config])
}
Error in extension:
fault: Attempt to add read-only file at path file:///private/var/mobile/Containers/Shared/AppGroup/51431199-5919-4AE6-940C-6FE3C53EEB46/default.sqlite read/write. Adding it read-only instead. This will be a hard error in the future; you must specify the NSReadOnlyPersistentStoreOption.
error: (3) access permission denied
error: Encountered exception error during prepareSQL for SQL string 'SELECT TBL_NAME FROM SQLITE_MASTER WHERE TBL_NAME = 'Z_METADATA'' : access permission denied with userInfo {
NSFilePath = "/private/var/mobile/Containers/Shared/AppGroup/51431199-5919-4AE6-940C-6FE3C53EEB46/default.sqlite";
NSSQLiteErrorDomain = 3;
} while checking table name from store: <NSSQLiteConnection: 0x154100300>
error: Store failed to load. <NSPersistentStoreDescription: 0x15402d590> (type: SQLite, url: file:///private/var/mobile/Containers/Shared/AppGroup/51431199-5919-4AE6-940C-6FE3C53EEB46/default.sqlite) with error = Error Domain=NSCocoaErrorDomain Code=256 "The file “default.sqlite” couldn’t be opened." UserInfo={NSFilePath=/private/var/mobile/Containers/Shared/AppGroup/51431199-5919-4AE6-940C-6FE3C53EEB46/default.sqlite, NSSQLiteErrorDomain=3} with userInfo {
NSFilePath = "/private/var/mobile/Containers/Shared/AppGroup/51431199-5919-4AE6-940C-6FE3C53EEB46/default.sqlite";
NSSQLiteErrorDomain = 3;
}
Any help appreciated 🙂
Topic:
App & System Services
SubTopic:
General
Tags:
Family Controls
Managed Settings
Screen Time
SwiftData
I use DeviceActivityCenter to monitor app usage.
For DeviceActivityEvent, I set 30 events, and the threshold of each event increases by 2 minutes:
var events: [DeviceActivityEvent.Name: DeviceActivityEvent] = [:]
for index in 0..<30 {
let threshold = (index == 29)
? DateComponents(hour: 1)
: DateComponents(minute: (index + 1) * 2)
let name = DeviceActivityEvent.Name("\(prefix)|\(index)")
events[name] = DeviceActivityEvent(applications: tokens, threshold: threshold)
}
After reaching the last DeviceActivityEvent, I will restart directly in DeviceActivityMonitor
private func restartMonitoring(activity: DeviceActivityName) {
let center = DeviceActivityCenter()
let currentEvents = center.events(for: activity)
do {
try center.startMonitoring(activity, during: schedule, events: currentEvents)
} catch {
print("Fail: \(error)")
}
}
But I found that after restarting, DeviceActivityEvent will be automatically executed even if I don't use the app.
My iOS version is 18.5
Hello,
I am thinking of developing a parental control app but I do not know if I need to request the api for using "Time Screen API". In positive case, where it should be?
Is there anyway to use this for educational centers? Not just for families?
Kind regards.
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect API
Tags:
Frameworks
App Store Connect API
Family Controls
Hello! I am a relatively new Apple developer and am almost done with my first app. I am implementing the Screen Time API to my app because the app is designed to help the user digitally detox and I am trying to make it so the user can select which apps they would like to monitor from a list of their apps on their phone so I am using the family activity picker but I just can't extract the data needed to track the apps. I am wondering how to do this. Thank you!
Topic:
App & System Services
SubTopic:
General
Tags:
Frameworks
Family Controls
Device Activity
Screen Time
Is there any way to use the screen time API on Mac?
I’m creating an app with the Screen Time API and I would like to know how to make the app show a parental control editing view for parents and a view for child accounts that shows which apps are blocked. How can I do this?
Hello,
I’m presenting the familyActivityPicker from a presented sheet in my application.
When I select some apps, categories or websites and tap “Done”, the familyActivityPicker is dismissed but the presenting sheet is also dismissed on iOS 18.4, iOS 18.5, iOS 26 beta 1 and 2. If I tap on “Cancel” from the familyActivityPicker, the sheet is also dismissed on iOS 18.4, iOS 18.5, iOS 26 beta 1 and 2.
The same code works perfectly fine on iOS 18.0, iOS 18.1, iOS 18.2 and iOS 18.3.
Is this a known-issue?
If opened the feedback FB18369821 for this.
Regards,
Axel
Topic:
App & System Services
SubTopic:
General
Tags:
SwiftUI
Family Controls
Managed Settings
Screen Time
I found that in iOS 18.5, DeviceActivityCenter startMonitoring cannot start multiple monitors, even if their names and periods are different, and restarting the phone cannot solve it. My app uses DeviceActivityCenter, which makes the entire function unusable. (I have less than 20 monitors)
Topic:
App & System Services
SubTopic:
General
Tags:
Family Controls
Device Activity
Managed Settings
Hello everyone,
I’m developing an app using the FamilyControls framework, I distributed through TestFlight the other day using the “Family Controls” distribution (not Development). Everything works as expected in dev builds — but for external TestFlight testers, nothing in the FamilyControls framework seems to function.
I'm using the correct Family Controls capability in Xcode (added via Signing & Capabilities).
The com.apple.developer.family-controls entitlement is present in my .entitlements file.
All the users who reported the issue had correctly given screen time permissions to the app.
Would really appreciate some help regarding where the issue could come from.
I’m in crisis mode and desperately need advice. Launching in 10 days and just hit a major roadblock.
Background:
Set up developer account under a business name only because we needed the D-U-N-S number when starting development
Have a working app with Family Controls already configured on the main identifier
Yesterday my developer discovered we need Family Controls on 3 additional identifiers for launch
a week ago (terrible timing) I submitted a business name change request thinking it was good housekeeping
The Crisis:
Certificates, Identifiers & Profiles portal is completely locked during business name change processing
Can’t add Family Controls to the 3 identifiers we need for launch
Business name change typically takes 2-4 weeks
Launch is in 10 days
What I’ve Done:
Contacted Apple Developer Support explaining the urgency
Case ID: 102633553000 for the name change request
Desperate Questions:
Has ANYONE successfully cancelled a business name change mid-process for urgent app needs?
Any emergency escalation paths at Apple for launch-blocking issues?
Would creating a new developer account be faster? (Though that seems nuclear)
Any other workarounds I’m not thinking of?
The business name change was purely administrative - nothing structural changes. But these identifier updates are absolutely critical for launch functionality and we didn’t realize they were needed until trying to launch into testflight.
This is our first time so learning a lot the hard way 🫠.
Thanks in advance for any help!
Topic:
Developer Tools & Services
SubTopic:
Apple Developer Program
Tags:
Entitlements
Family Controls
I am trying to create an app that allows users to opt in and apply a shield to all of their apps during a specified amount of time each day, but they can always turn the shield off from our app or directly ignore the shield for 1 minute from a shield button. It is important that the user doesn't choose what apps to apply a shield to through the activity picker, as some users might not apply it to all apps.
Currently I am doing everything I described in my app and shield all apps and webdomain categories with this:
store.shield.applicationCategories = .all()
store.shield.webDomainCategories = .all()
But the, store.shield.applicationCategories = .all(), seems to block everything except for some system apps like Messages, Phone, FaceTime, Maps, Clock, Settings, Safari, Find My, Clock, Compass, Health, etc. It does block some system apps like Weather, Photos, Camera, Measure, App Store, etc.
I know I can fully block applications from it's bundle identifier but I do not want to remove apps from the home screen. I only want to apply a shield to all of them. I have read every apple documentation possible about this and can't see a way to do it, currently how I am doing it seems to be the best way but it is still not enough. Even blocking a specific category token taken from the activity picker won't apply to some system level applications under it unless you get all the application tokens and apply the shield by applications and not category.
I am really looking for help to see if there is something I can do to achieve my app's goal.
So when we select an app that needs to have a shield configured for family controls (managed settings), when selecting an individual application (say like Instagram), it works well but when I select a whole category (say like Social) it doesn't work well. here's the exact code for how I choose which application needs to be shielded:
class ShieldConfigurationExtension: ShieldConfigurationDataSource {
override func configuration(shielding application: Application) -> ShieldConfiguration {
return ShieldConfiguration(
backgroundBlurStyle: .systemChromeMaterial,
backgroundColor: UIColor(red: 220.0/255, green: 20.0/255, blue: 60.0/255, alpha: 1.00),
icon: iconImage,
title: ShieldConfiguration.Label(text: "You CAN'T give up now!", color: .white),
subtitle: ShieldConfiguration.Label(text: "Just a little bit more you got this", color: .white),
primaryButtonLabel: ShieldConfiguration.Label(text: "GRINDSET", color: .white),
primaryButtonBackgroundColor: .black,
secondaryButtonLabel: ShieldConfiguration.Label(text: "Move Fast", color: .black)
)
}
Now this works well for application selection alone, but there isn't any for category selection as such. And the same is shown in its execution that a category goes back to default shielding. What API should I use for category shielding?
I'm new to the Screen Time API and trying to block custom websites, but I can't get WebDomain tokens to work. When I create a WebDomain like WebDomain(domain: "reddit.com"), the token property is always nil. I have proper authorization and the app works fine for blocking apps, but website blocking just won't work.
I'm confused because I see apps like JOMO that let users type in any website domain and successfully block it using Screen Time API. They have the same 49 domain limit and only ask for Screen Time permission, so they must be using the same API I am. But somehow their WebDomain tokens work and mine don't.
I've tried creating the tokens right after getting authorization and during the FamilyActivityPicker session, but still get nil. Am I missing some setup step or API call that makes WebDomain tokens valid? Any help would be really appreciated since I'm stuck on this.
Hello everyone,
I'm facing a critical build issue related to Family Controls entitlements and would appreciate any insights or help from the community or Apple engineers.
My Goal:
I am trying to build and run my app on a physical device to test my DeviceActivityMonitor and ShieldConfigurationExtension. I have already been approved for the Family Controls (Development) entitlement.
The Problem:
When I try to build, Xcode fails with the following errors, preventing me from testing:
For my DeviceActivityMonitor target:
Provisioning profile "..." doesn't include the com.apple.developer.deviceactivity entitlement.
For my SOSAppShieldExtension target:
Provisioning profile "..." doesn't include the com.apple.developer.screen-time-api entitlement.
The Core Evidence:
This seems to be a server-side issue with how the provisioning profiles are generated. I have used the security cms -D -i command to inspect the downloaded .mobileprovision files.
The inspection reveals that the profiles do contain the parent com.apple.developer.family-controls entitlement. However, they are missing the required child entitlements:
The profile for my monitor extension is missing com.apple.developer.deviceactivity.
The profile for my shield extension is missing com.apple.developer.screen-time-api.
Troubleshooting Steps I've Already Taken:
I believe I have exhausted all possible client-side fixes. Here is what I have tried over the past few days:
Confirmed Approval: I am fully approved for the Family Controls (Development) entitlement.
Enabled Capabilities: The "Family Controls" capability is checked and enabled for all three relevant App IDs (main app, monitor extension, shield extension) on the developer portal.
Profile Regeneration: I have deleted and regenerated all provisioning profiles for all targets multiple times.
Forcing a Server Refresh: I have toggled the "Family Controls" capability off, saved, and then toggled it back on and saved again for each App ID.
Creating New Identifiers: I created a brand new, clean App ID for the DeviceActivityMonitor extension (com.sosapp.ios.devicemonitor) and created a new profile for it, but the error persists.
Xcode Configuration: I am using manual signing in Xcode and have double-checked that each target is pointing to the correct, newly downloaded provisioning profile. I have also cleaned the build folder and deleted Derived Data multiple times.
My Question:
Given that my account is approved and the capability is enabled, but the generated profiles are provably missing the necessary child entitlements, this points directly to a bug in the profile generation service on Apple's backend.
Has anyone else experienced this specific issue where the parent entitlement is present but the required child entitlements are missing? Is there a known workaround, or can an Apple engineer please investigate the profile generation for my Team ID?
Any help would be greatly appreciated. Thank you!
Hey there! So, I'm trying to see what I'm able to do with the Device Activity Report Extension, and I have a few questions about the following quote:
To protect the user’s privacy, your extension runs in a sandbox. This sandbox prevents your extension from making network requests or moving sensitive content outside the extension’s address space.
In particular, what constitutes the address space for this extension?
Can I save data to a UserDefaults object that only the extension can access? (Apps like Opal allow the user to label apps as "distracting" and "non-distracting", and I'm wondering how they do that!)
From what I've read, I believe it cannot write to a shared app group or model (and I just want to confirm this)
It also seems that there's nothing preventing it from reading data from the main app, so I'm just wondering if it's able to read data from an app group or model with no problem.
Thanks in advance!
Topic:
App & System Services
SubTopic:
General
Tags:
Family Controls
Device Activity
Screen Time
Privacy
Hello, I am trying to display basic screen time data on my main screen. On the initial load of the screen, the DeviceActivityReport renders correctly and visible, but after being in the background and coming back to the app, the whole view is just blank. I don't think I'm doing anything special. Is this a known bug?
@main
struct MyActivityReportExtension: DeviceActivityReportExtension {
var body: some DeviceActivityReportScene {
// Create a report for each DeviceActivityReport.Context that your app supports.
TotalActivityReport { totalActivity in
TotalActivityView(totalActivity: totalActivity)
}
// Add more reports here...
}
}
extension DeviceActivityReport.Context {
// If your app initializes a DeviceActivityReport with this context, then the system will use
// your extension's corresponding DeviceActivityReportScene to render the contents of the
// report.
static let totalActivity = Self("Total Activity")
}
struct TotalActivityReport: DeviceActivityReportScene {
// Define which context your scene will represent.
let context: DeviceActivityReport.Context = .totalActivity
// Define the custom configuration and the resulting view for this report.
let content: (String) -> TotalActivityView
func makeConfiguration(representing data: DeviceActivityResults<DeviceActivityData>) async -> String {
// Reformat the data into a configuration that can be used to create
// the report's view.
let formatter = DateComponentsFormatter()
formatter.allowedUnits = [.day, .hour, .minute]
formatter.unitsStyle = .abbreviated
formatter.zeroFormattingBehavior = .dropAll
let totalActivityDuration = await data.flatMap { $0.activitySegments }.reduce(0, {
$0 + $1.totalActivityDuration
})
return formatter.string(from: totalActivityDuration) ?? "No activity data"
}
}
struct TotalActivityView: View {
let totalActivity: String
var body: some View {
VStack(alignment: .center, spacing: 4) {
Text("Screen Time")
.font(.system(size: 14, weight: .regular))
.foregroundColor(.secondary)
.frame(maxWidth: .infinity, // stretch to the full cell width
alignment: .center)
Text(totalActivity)
.font(.system(size: 18, weight: .medium))
.foregroundColor(.primary)
}
}
}
And I am using it in my main view:
private var analyticsSection: some View {
HStack(spacing: 24) {
// Some View
DeviceActivityReport(DeviceActivityReport.Context(rawValue: "Total Activity"), filter: DeviceActivityFilter(
segment: .weekly(
during: Calendar.current.dateInterval(
of: .weekOfYear, for: .now
)!
),
users: .all,
devices: .init([.iPhone, .iPad]),
))
.frame(maxWidth: .infinity)
// another view
}
.frame(maxWidth: .infinity, maxHeight: showAnalytics ? 58 : 0)
.padding(.horizontal, showAnalytics ? 24 : 0)
.opacity(showAnalytics ? 1.0 : 0.0)
.clipped()
}
Hi All,
Like many others I'm a little confused with gaining access to the family controls capability.
Our app is ready to push to testflight, and we sent the request to apple last week. However only learning today that we need to request for the shield extension as well.
I wanted to ask what the expected timeline is for being approved?
I've seen posts here saying less than a week, and some people having to wait longer than 6 weeks.
Any advise or guidance on getting approved smoothly & swiftly would be highly appreciated
I'm working on an app for iOS that will help people get tasks done.
Within the app, we use a ManagedSettingsStore to let the user setup distracting apps. When the user opens any of those apps while it is being shielded, our ShieldConfiguration target opens and displays a screen that we configure with the description of the task they are supposed to do. On the bottom of the view, there are two buttons, one to start the task, and another to dismiss and return to their home screen.
I want to have the button that starts the task open up the main application and deeplink to the focus view with the task that they started. Currently, the only thing that we can tell the system to do is via a ShieldActionResponse which is an enum with 3 cases: none, close, or defer.
None of these three allow us to open the main application. I have found no workarounds that allow us to do it either. I've tried creating a custom URL scheme and calling UIApplication.shared.open(url), but there is no shared application available within the action extension. I have tried using a NSExtensionContext to open a url, but that does not work either. I have even tried starting a live activity to show the user what task they are working on and have a live timer, but that does not work either.
I know it is technically possible, because an app I downloaded does it perfectly. The app is called "Ascent: Screen Time Control". Is there some sort of extension I am missing, or entitlement I have not requested? Any help would be very appreciated.
Topic:
App & System Services
SubTopic:
General
Tags:
Family Controls
Device Activity
Managed Settings
Screen Time