Am showing daily screen-time of a user in my app in Device Activity Report Extension. The only way to get that is to sum up all the activityDuration of apps/categories/domains. But it differs a lot from phone's settings screen-time, why?
I have debugged in details and counted manually the time spent on each app and it turned out that the calculation is appearing correctly in my app but Phone settings showing quite less time on top (Day).
Screen Time
RSS for tagShare and manage web-usage data, and observe changes made to Screen Time settings by a parent or guardian.
Posts under Screen Time tag
170 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
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.
After setting up all permissions, family members not showing up on the device list
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!
Hi everyone,
I’m working on my submission for the Swift Student Challenge and need some advice. I already have an existing app that’s live on the App Store, and I’d like to use the same app for my submission.
However, while creating the App Playground, I noticed that I’m unable to create additional targets. This is problematic because my app relies heavily on specific targets like ShieldAction, ShieldConfiguration, and DeviceActivityMonitor. Without these targets, the app’s core functionality won’t work as intended.
Is there a known limitation or workaround for this? How can I submit my app’s functionality within the constraints of the App Playground?
Thanks in advance for your help!
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!!
I'm a complete newbie to Swift and app development, but I'm playing around with an idea that uses the ScreenTime API.
Some of the articles (and AI) mention that you need to request access through Apple to use this, but based on my research it seems like this is a bit outdated.
Can anyone provide a clear answer here + any resources you've used to navigate this? The documentation is pretty sparse.
Thank you in advance!
This is more a general question of whether it is possible to share persistent/coredata from the main app to Screentime-related extensions such as DeviceActivityReportExtension.
I've set my code up (e.g., App Groups, files to different targets, using nspersistentcontainer with app group url, etc.) in a way that it builds, and the extension seems to recognize my CoreData schema (able to query using fetchrequest). But the data returned is always null. So i'm wondering if it is even possible to READ app data from the extension.
I understand it is not possible to write or pass data from the extension back to the app. I've also been able to read data that was saved in main app from UserDefaults in my extension.
I'm trying to accomplish the features in this video where the child device requests permission from parent to control scren time. Then the parent can choose apps on the childs phone from their phone.
Everything on the childs device is working exactly like in the video. However, on the parents phone, when the FamilyActivityPicker appears, it's only the apps on the parents phone and when an app is selected, nothing changes in the FamilyActivitySelection.
I found this forum post describe the same issue I am having. I have a physical device logged in the child and a simulator running as the parent.
Why can't I see the child's apps on the parents phone? Is it cause I'm running one of them on a simulator?
I am working on a SwiftUI app using the Screen Time API and the DeviceActivityReport view to display app usage data. My current implementation successfully shows daily app usage using a DeviceActivityFilter with the .daily(during:) segment. However, I need to filter this data to show app usage only for a specific time period during the day, e.g., 4:00 PM to 5:00 PM.
I created a DeviceActivityFilter with a .daily(during:) segment and passed a DateInterval for the desired time range:
let now = Date()
let startTime = calendar.date(bySettingHour: 16, minute: 0, second: 0, of: now)!
let endTime = calendar.date(bySettingHour: 17, minute: 0, second: 0, of: now)!
let timeInterval = DateInterval(start: startTime, end: endTime)
let filter = DeviceActivityFilter(
segment: .daily(during: timeInterval),
users: .all,
devices: .init([.iPhone])
)
I applied this filter to the DeviceActivityReport view:
DeviceActivityReport(context, filter: filter)
Even with the DateInterval set for the specific time range, the report still shows the total daily usage for each app, instead of restricting the results to the specified 1:00 PM to 5:00 PM range.
Hello
I am wondering how and if it even is possible to grab the amount of times a user has opened a specific app. Of course these apps will be selected for tracking by the user through the FamilyControls API, but is it possible to then list those selected apps and their amount of openings?
I know Screen Time API is very strict with giving developers control of this information outside of just displaying a view so I don't know if this is possible.
I saw that DeviceActivityData.ApplicationActivity has a value called "numberOfPickups" but I'm not sure how to access that value and display it in my app.
Thank you
I applied for the Family Controls (Distribution) entitlement on November 22nd. But I never received a confirmation email after I submitted the request.
I then reached out to support who said they would check with the internal team to at least confirm if I had applied.
It's now been 20 days and I have received no updates on the status of my application.
This entitlement is existential to my app and I have been completely blocked while waiting for this as I can't even distribute the app on TestFlight.
I've considered reapplying again just to be safe, but I am worried that might make things worse.
I am a bootstrapped solo founder, and a prolonged delay (or outright denial) of this entitlement would be devastating to me.
Does anyone have any advice on where to go from here?
Hi everyone,
I've been going through the forums and documentation, but I'm still unsure about how the Screen Time API works or whether it can achieve what I have in mind.
Specifically, I want to display the current screen time value on a widget. Additionally, I’d like to use that screen time value for some calculations and represent the results in a different way within the widget.
I’d really appreciate any guidance or insights. Thanks in advance! 😊
I am getting this error when I try to show device activity report view by this
DeviceActivityReport(appsContext, filter: filter)
Attempt to map database failed: permission was denied. This attempt will not be retried.
I have taken access by this way.
AuthorizationCenter.shared.requestAuthorization(for: .individual)
Hello, we are building an app to limit children's screen time and using Screen Time API. We found bug on the screen where the user selects app category and apps, if the user selects Other category, the screen will crash (he will be empty, but if you reload screen, it will show apps again as usual). We hope that Apple will fix it someday, but we are trying to notify our users about this problem, and the problem is that we don't know what the user selects on Apple screen with apps till the user clicks Save or Done. But we need to notify him either when he clicks on the Other category or when he faces crash of this screen. We want to show a pop-up to user with explanation why screen crashed.
When I use the screen time API, the app occasionally crashes in the morning. I mean the UI freeze lasts for more than ten seconds.
But the weird thing is that I work normally during the day, that is, in the morning, when I just woke up. (There is no Do Not Disturb mode). This problem has been bothering me for several days, please help.
The specific crash log is as follows, and the specific code is as follows.
Model: iPhone 15 Pro, iOS: 18.1.1
Thanks for your help!
Code:
private func startAppMonitoring(application: ApplicationToken, seconds: Int, isFromNow: Bool) {
let schedule = DeviceActivitySchedule(
intervalStart: isFromNow ? Calendar.current.dateComponents([.hour, .minute, .second], from: Date()) : DateComponents(timeZone: TimeZone(identifier:TimeZone.current.identifier), hour: 0, minute: 0, second: 0),
intervalEnd: DateComponents(timeZone: TimeZone(identifier:TimeZone.current.identifier), hour: 23, minute: 58, second: 59),
repeats: true,
warningTime: DateComponents(minute: 1)
)
let event = DeviceActivityEvent(
applications: Set([application]),
threshold: DateComponents(second: seconds)
)
let center = DeviceActivityCenter()
do {
try center.startMonitoring(DeviceActivityName("\(application.hashValue)Usage"), during: schedule, events: [DeviceActivityEvent.Name("\(application.hashValue)Event"): event])
} catch {
print("Error starting monitoring schedule: \(error)")
}
}
Crash report:
I'm working with the FamilyControls API and am running into an issue with sharing ActivityTokens between devices in the same family sharing network.
Based on this documentation, ActivityTokens are only accessible and readable by other members in the family sharing network. My app is based on the idea that if one user selects the Games category in the FamilyActivityPicker, then this token can be shared with another device in the same family-sharing network and this other device can read and display the category.
So my question is:
If a user in the network selects an activity category in the FamilyActivityPicker, can this category token be shared, read, and used by another user in the family-sharing network?
I'm currently working with the FamilyControls API and testing my app on two different devices. Both apps are in the same family-sharing network with one phone being the owner of the network (I'll call this A) and the other one being an adult in the network(I'll call this B).
When device A picks apps using the FamilyActivityPicker, it shares that selection with device B (via encoding, sending over network, and decoding on device B). However, interacting with the token (displaying it, using it in shield) throws an error saying the token is null.
From the documentation, I thought every token would be the same across all devices in the family sharing network. So my question:
How do I send the FamilyActivitySelection from A to B and have the tokens still be functional?
Does this functionality only work if A is a "parent" and B is a "child" in the family sharing network?
Also, side note:
If I reverse the process and send the tokens from B to A. Interacting with the token works exactly as expected. For some reason, it's only going from A to B where it doesn't work.
Hi everyone, I need to display a Graph based on Screen-time of apps per hour, from 12Am to 11PM. Am able to get the screen-time data for whole day with each app's total screen-time value.
Am kind of confused how can I get the per hour screen-time of apps. I have applied filter of day
DeviceActivityFilter(
segment: .daily(
during: Calendar.current.dateInterval(
of: .day, for: .now
)!
),
users: .all,
devices: .init([.iPhone, .iPad])
)
Am also using this data to display apps with their usage just like Apple's Screen_time in settings.
I need to display exact same graph just like Apple's screen in phone settings for a Day.
I made this strange discover yesterday.
MacOS 15.2 beta 3, Macbook Pro 2020
One one member and one device, no family sharing or more devices included.
Ideas?