I am encountering an issue after transferring an app that uses the FamilyControls framework to a different app account. After releasing a new version of the app post-transfer, the following problems arose:
ApplicationTokens obtained in the pre-transfer version no longer function when used with ManagedSettingsGroup.ShieldSettings in the post-transfer version.
Using the same ApplicationTokens with Label(_ applicationToken: ApplicationToken) does not display the app name or icon.
These issues did not occur in the pre-transfer version and everything worked as expected. We suspect that ApplicationTokens obtained prior to the transfer are no longer valid in the updated app released under the new app account.
We are seeking guidance on the following:
Is this expected behavior after transferring an app to another app account?
What steps should we take to ensure that ApplicationTokens obtained before the transfer remain functional in the post-transfer environment?
If these tokens are invalidated due to the transfer, what are the recommended procedures for regenerating or updating ApplicationTokens for existing app users?
Maintaining a seamless user experience after transferring the app is critical. We would greatly appreciate any insights or guidance. Please let us know if additional information or logs would assist in investigating this issue.
Thank you!
Family Controls
RSS for tagPrevent access to the Screen Time API without guardian approval and provide opaque tokens that represent apps and websites.
Posts under Family Controls tag
191 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
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.
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?
let schedule = DeviceActivitySchedule(
intervalStart: startInterval,
intervalEnd: endInterval,
repeats: false,
warningTime : DateComponents(hour : 0 , minute: 0 , second: 30)
)
```
I hope it will only be executed on the same day, but the monitoring is still there the next day. My system version is 18.2
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)
When I attempt to distribute my app in Xcode, I get the following error:
Can I resolve the above error by applying for permissions?
I learned from this thread that the above application was not approved by email. How can I know whether the application was approved?
In addition, from this thread, the review process may take several weeks or even 5 months. Considering that public holiday is coming, how can I speed up this process? ( I have submitted my application)
Thank you
I am developing an application that utilizes Family Controls to restrict the use of certain apps. Currently, I am using the following extensions: DeviceActivityMonitor, ShieldConfiguration, and ShieldAction.
Issue Overview: While blocking a single application functions correctly, a problem arises when implementing multiple functionalities that use these extensions for the same application.
STEPS TO REPRODUCE
Functionality 1: Maximum Time in App
Description: Blocks the app after 15 minutes of continuous use.
Functionality 2: Conscious Opening
Description: Upon opening the app, it is blocked for 10 seconds and then automatically unlocked.
Steps to Reproduce the Bug:
Open the Application:
The app opens normally.
Trigger Functionality 2
The app is blocked and displays the blocking screen corresponding to Functionality 2: Conscious Opening.
Continue Using the App
After 10 seconds, the app unlocks, and I continue using it.
Important: If the app is closed at this point, the bug does not occur.
Trigger Functionality 1 After 15 Minutes
After 15 minutes of continuous use, the app should block according to Functionality 1: Maximum Time in App.
Expected Behavior: The blocking screen for Functionality 1 is displayed.
Actual Behavior: The blocking screen for Functionality 2 is displayed instead.
Technical Observations:
By adding logs in ShieldConfiguration, I observed that the configuration does not refresh correctly when the app is blocked a second time while still in use.
If the app is closed and reopened, the correct blocking screen for Functionality 1 is displayed as expected.
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?
When using DeviceActivityMonitorExtension, I found that when repeats in DeviceActivitySchedule is true, the same DeviceActivityEvent under DeviceActivity on the next day will be triggered twice.
What I did wrong?
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?
I have a app with two targets: a main DeviceActivityApp target and a DeviceReport target. In the DeviceReport target, I have a TotalActivityReport struct conforming to DeviceActivityReportScene. Inside its makeConfiguration method, I update a dynamically generated list of AppReport items. The list updates correctly in the DeviceReport target.
// 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: (MonitorDeviceReport) -> TotalActivityViewFirst
@ObservedObject var activityData:ActivityData
func makeConfiguration(representing data: DeviceActivityResults<DeviceActivityData>) async -> MonitorDeviceReport {
// Reformat the data into a configuration that can be used to create
// the report's view.
var appList:[AppsReport]=[]
let totalActivityDuration = await data.flatMap { $0.activitySegments }.reduce(0, {
$0 + $1.totalActivityDuration
})
for await _data in data{
for await activity in _data.activitySegments{
for await category in activity.categories{
for await app in category.applications{
let name=app.application.localizedDisplayName ?? "No Name"
let bundleId=app.application.bundleIdentifier ?? "nil"
let duration=app.totalActivityDuration
let appIcon=app.application.token
let app=AppsReport(id:bundleId,duration:duration, name:name, icon:appIcon)
appList.append(app)
}
}
}
}
DispatchQueue.main.async {
activityData.list=appList
}
return MonitorDeviceReport(duration:totalActivityDuration, apps:appList)
}
}
public class ActivityData:ObservableObject{
@Published var list:[AppsReport]=[]
public static let shared = ActivityData()
}. // This is in MonitorReport target
However, I need to access this dynamic list in my MyApp target, specifically in ContentView.swift. I tried using an ObservableObject (ActivityData) to share the data between targets, but the list always appears empty in the MyApp target.
Here’s what I’ve tried so far:
Created a shared ActivityData instance using @Published
Passed the ActivityData instance to TotalActivityReport
Used dependency injection and a singleton pattern for ActivityData
Verified that makeConfiguration updates the list correctly in DeviceReport
What could I be missing? How can I correctly share and access this data across targets?
DeviceActivityReport presents statistics for a device: https://developer.apple.com/documentation/deviceactivity/deviceactivityreport
The problem: DeviceActivityReport can present statistics with a delay for a parent device (when DeviceActivityReport is presenting, the DeviceActivityReportExtension is called to process the statistics). One possible solution is to call DeviceActivityReport periodically throughout the day in a child device. However, the app will not be available all day. Is there any way to run DeviceActivityReport in the background?
I have tried the following approach, but it didn’t work (DeviceActivityReportExtension didnt call):
let hostingController: UIHostingController? = .init(rootView: DeviceActivityReport(context, filter: filter))
hostingController?.view.frame = .init(origin: .zero, size: .init(width: 100, height: 100))
hostingController?.beginAppearanceTransition(true, animated: false)
hostingController?.loadView()
hostingController?.viewDidLoad()
try? await Task.sleep(for: .seconds(0.5))
hostingController?.viewWillAppear(true)
hostingController?.viewWillLayoutSubviews()
try? await Task.sleep(for: .seconds(0.5))
hostingController?.viewDidAppear(true)
try? await Task.sleep(for: .seconds(0.5))
hostingController?.didMove(toParent: rootVC)
try? await Task.sleep(for: .seconds(0.5))
hostingController?.viewWillLayoutSubviews()
hostingController?.viewDidLayoutSubviews()
hostingController?.view.layoutIfNeeded()
hostingController?.view.layoutSubviews()
hostingController?.endAppearanceTransition()
Is there any way to run DeviceActivityReport in the background? (when app is not visible/closed). The main problem is call DeviceActivityReport
I am working on the device activity report. and fetched data is loading on the chart. I am developing app using TabbarController. when I go to another tab and come back to the chart screen, it disappears.
Here, I am working on a storyboard using Swift language, and device activity reports can be fetched only with SwiftUI. So, the problem is with it? Following the current code.
@State private var context: DeviceActivityReport.Context = .init(rawValue: "Daily Activity")
@State private var report: DeviceActivityReport?
@State private var filter = DeviceActivityFilter(
segment: .daily(
during: Calendar.current.dateInterval(
of: .day, for: .now
)!
)
// users: .all
// devices: .init([.iPhone, .iPad])
)
@State var isReload: Bool = false
var body: some View {
ZStack {
if isReload {
LoadingView(title: "Data is loading...")
} else if let report = report {
report
} else {
DeviceActivityReport(context, filter: filter)
}
}
.onAppear {
DispatchQueue.main.async {
report = DeviceActivityReport(context, filter: filter)
}
}
}
struct LoadingView: View {
var title: String = "Please wait..."
var body: some View {
HStack {
ProgressView(title)
.font(.system(size: 14, weight: .medium))
.progressViewStyle(.horizontal)
.tint(Color(.darkGray))
.padding(8)
}
.background(Color(.white))
.cornerRadius(8)
.clipped()
}
}
When I try to load the device activity report, it takes too long to load data. Is this because of development time? Will the problem be solved when the app is live on the App Store?
If it does not depend on the development profile, then please give me a solution for the fast data loading in the device activity report extension.
Thank you
Bonjour le temps d’écran de mon enfant dans le partage familial ne fonctionne plus. Quand est ce qu’on aura une correction ?