Search results for

DeviceActivityReport

118 results found

Post

Replies

Boosts

Views

Activity

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
1
0
549
Oct ’24
Reply to Cannot get DeviceActivityReport to work
Leaving this here for the next person who needs help: lets say you have this in your context: 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(totalActivity) } You have to put this in your actual app AND in your DeviceActivityReport extension.
Topic: Privacy & Security SubTopic: General Tags:
Feb ’23
App with DeviceActivityReport extension either won't install on device or won't upload to TestFlight
We have integrated DeviceActivityReport to our Family Controll app. All capabilities are added. We built the app and tested it, but when we want to upload to TestFlight the following error happened (see attached image) When we are adding NSExtensionMainStoryboard or NSExtensionPrincipalClass the following error appears during installation process. DeviceReport.appex with id com.example.example.DeviceReport defines either an NSExtensionMainStoryboard or NSExtensionPrincipalClass key, which is not allowed for the extension point com.apple.deviceactivityui.report-extension
2
0
765
Jan ’24
How long is DeviceActivityData accessible in DeviceActivityReport?
Using the DeviceActivity framework we are able to display data based on a user's screentime and device usage. With the DeviceActivityFilter property, you can specify the date interval to collect data between. In testing, it seems that data only becomes accessible once the extension has been installed (so the extension isn't reading the screentime data already collected on device). However, once installed, I'm curious how far back you can query data from in the data interval? Opal which uses the Screentime API appears to have a lifetime Screentime metric, so hypothetically it should possible to query data as far back as collection starts. Unless they are getting around the sandbox environment and storing the data somehow. Side note on Opal -- They seem to have a community average of Screentime among people in the same age group. Does anyone know how they are collecting the data for this average? Is it actually using live Screentime data or just aggregating data from other studies?
2
0
1.1k
May ’23
DeviceActivityReport inside SwiftUI Button doesn’t receive tap gestures (ScreenTime API, iOS 17+)
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 Scro
1
0
199
May ’25
Reply to I need to show app usage time in my app
There is some sample code for how to use a DeviceActivityReport within your app's view hierarchy here: https://developer.apple.com/documentation/deviceactivity/deviceactivityreport As for how to implement an extension that renders the report's UI based on usage data, if you select File > New > Target... > iOS > Device Activity Report Extension in Xcode, it will create a simple extension that you can then modify to fit your app's use case. If this is not sufficient, please file a request for supplemental sample code using Feedback Assistant.
Topic: App & System Services SubTopic: General Tags:
Sep ’22
How can I open and write to an SQLite database from my DeviceActivityReport Extension?
Hello everyone, I’m working on an iOS app that uses the new DeviceActivity framework to monitor and report user screen‐time in an extension (DeviceActivityReportExtension). I need to persist my processed screen‐time data into a standalone SQLite database inside the extension, but I’m running into issues opening and writing to the database file. Here’s what I’ve tried so far: import UIKit import DeviceActivity import SQLite3 class DeviceActivityReportExtension: DeviceActivityReportExtension { private var db: OpaquePointer? override func didReceive(_ report: DeviceActivityReport) async { // 1. Construct path in app container: let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: group.com.mycompany.myapp) let dbURL = containerURL?.appendingPathComponent(ScreenTimeReports.db) // 2. Open database: if sqlite3_open(dbURL?.path, &db) != SQLITE_OK { print(❌ Unable to open database at (dbURL?.path ?? unknown path)) return } defer { sqlite3_close(db) } // 3. Create tabl
1
0
180
May ’25
DeviceActivityReport shows 0 screen time data during a daily segment interval
Since Monday March 13 2023, DeviceActivityReport with a daily segment filter shows 0 screen time, for all users of my app (there are thousands). When changing the segment to hourly, it works but performance suffers. I've defined the filter like this: @State private var filter = DeviceActivityFilter(segment: .daily(during: DateInterval( start: Calendar.current.startOfDay(for: .now), end: .now))) Is anybody else experiencing this? This happened on its own after no change in the code or update to the app, and seems to be correlated with the first full day of Daylight Savings. I will file a bug in Feedback Assistant, but is there any other guidance you can give on what might be the root cause, and if there's a fix? Seems like a large issue. Thanks in advance!
1
0
1.2k
Mar ’23
How to show icons apps when retrieving DeviceActivityReport
Actually, I'm developing a new app based on screen time API, so I implemented my report device extension like this 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: (ActivityReport) -> TotalActivityView func makeConfiguration(representing data: DeviceActivityResults) 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 { let appName = (ap.applicati
0
0
695
Jun ’24
Reply to API Screen Time
You can use a DeviceActivityReport and build an extension that gets access to the totalActivityDuration for a daily activity segment. This time interval represents the total amount of time the device's screen was on.
Topic: App & System Services SubTopic: General Tags:
Nov ’22