Post not yet marked as solved
Hi! DeviceActivityMonitors methods IntervalDidStart, IntervalDidEnd and eventDidReachThreshhold do not seem to be called on my application. Has anyone found a solution to this problem. Thank you in advance.
Post not yet marked as solved
I've been trying to get something to work with the Screen Time API, but almost everything related to it is unimplemented.
I checked following links
Device Activity
https://developer.apple.com/documentation/DeviceActivity
Managed Settings
https://developer.apple.com/documentation/ManagedSettings
Family Control
https://developer.apple.com/documentation/FamilyControls
Checked videos
https://developer.apple.com/videos/play/wwdc2022/110336/
Problems I faced
FamilyActivityPicker does not list installed apps on either of the guardian's or child's devices, it only lists the categories.
There is no way to allow setting up of restrictions for individual kids, if we have many kids in family.
If anyone gone through the same problem please upvote or if anyone has a solution please share
Thanks
Post not yet marked as solved
When use the DeviceActivity api to create a DeviceActivityReport, all of the ApplicationActivity.application objects have a nil localizedDisplayName.
ApplicationActivity(application: ManagedSettings.Application(bundleIdentifier: Optional("com.netflix.Netflix"), token: nil, localizedDisplayName: nil), totalActivityDuration: 0.0, numberOfPickups: 0, numberOfNotifications: 1, isTrusted: true)
I see in the documentation for Application.localizedDisplayName the following:
In an extension that provides shield configurations, this property provides the app’s name. When you access this property outside that extension, the value is nil. See ShieldConfigurationDataSource in the Managed Settings UI framework for more information.
I am using the property in an extension that provides shield configurations so it should not be nil.
I do see that ManagedSettings.ActivityCategory.localizedDisplayName is set properly and that in its documentation that it has the same requirement with shield configurations.
CategoryActivity(category: ManagedSettings.ActivityCategory(identifier: Optional("DH1003"), token: nil, localizedDisplayName: Optional("Entertainment")), totalActivityDuration: 0.0, applicationActivities: [DeviceActivity.DeviceActivityData.ApplicationActivity(application: ManagedSettings.Application(bundleIdentifier: Optional("com.google.ios.youtube"), token: nil, localizedDisplayName: nil), totalActivityDuration: 0.0, numberOfPickups: 0, numberOfNotifications: 1, isTrusted: true), DeviceActivity.DeviceActivityData.ApplicationActivity(application: ManagedSettings.Application(bundleIdentifier: Optional("com.microsoft.smartglass"), token: nil, localizedDisplayName: nil), totalActivityDuration: 0.0, numberOfPickups: 0, numberOfNotifications: 3, isTrusted: true)], webDomainActivities: [])
Since categories' display names are being set correctly, this seems like a bug in the beta to me. Has anyone else seen this issue?
Post not yet marked as solved
To shield applications, we have to pass ApplicationTokens to DeviceAcvivityMonitorExtension. But I don't know the way.
I tried to pass it by using NSUserDefaults. However, it didn't work because ApplicationToken isn't encodable. So I can't save it in UserDefaults
Does anyone knows the way to pass ApplicationTokens to the Extension or another way to shield apps?
Post not yet marked as solved
I want to know the structure how to send restrict information from parent to child.
When parent sets restriction on parent's device, that information is reflected on the child's device and the child is restricted from using the app and device.
I want to know how the restrictions set on the parent's device are transmitted to the child's device. Also, I want to know how to do it. I could even call requestAuthorization and succeed.
Does anyone know this?
Post not yet marked as solved
Hi!
I'm playing around with the Screen Time API. I would like to let my app notify me every time I have used my device for 1 minute (any app). When I have been notified, I would like to reset the monitoring so that I will be notified again after another minute using my device.
I'm not sure how to accomplish this. In the main app, I currently start monitoring the following event with a schedule:
let event = DeviceActivityEvent(threshold: DateComponents(minute: 1))
let schedule = DeviceActivitySchedule(intervalStart: DateComponents(hour: 0, minute: 0, second: 1), intervalEnd: DateComponents(hour:23, minute: 59, second: 59), repeats: true)
Then, in the Device Activity Monitor Extension, I restart the same monitoring once the threshold is reached in eventDidReachThreshold.
However, eventDidReachThreshold is being called much more than once an hour. I have checked that I only have one monitoring event running, so duplicates does not seem to be a problem. So, my questions are:
Does my approach look OK? What am I missing?
Would this monitoring collect usage from all devices connected to the same Apple ID, i.e. my Mac, iPad, iPhones etc? If so, how can I make it only monitor usage on one of my devices (the iPhone running the app)?
I am unable to make any progress regarding DeviceActivityReport. The session from WWDC 2022 covers it very briefly.
What I (hopefully correctly) understood is that we need to create an extension of type Activity report and inside it implement the body which is DeviceActivityReportScene that will display the charts and what not.
And then in the app, we need to use DeviceActivityReport with SwiftUI to show the report which will be run in sandbox from the extension.
But I cannot get anything to show up on the screen. Even when my extension view is just a static text to verify something gets displayed.
I am trying to create the device activity report without any filter which should give me all activity data per the docs.
This is shown in the Xcode console for the view that uses DeviceActivityReport.
2022-06-17 18:08:47.219785+0200 DeviceActivityTest[9613:954204] [default] LaunchServices: store (null) or url (null) was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=66, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}
2022-06-17 18:08:47.219862+0200 DeviceActivityTest[9613:954204] [default] Attempt to map database failed: permission was denied. This attempt will not be retried.
2022-06-17 18:08:47.219911+0200 DeviceActivityTest[9613:954204] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=66, _LSFunction=_LSServer_GetServerStoreForConnectionWithCompletionHandler}
2022-06-17 18:08:47.290070+0200 DeviceActivityTest[9613:954204] [default] Remote viewcontroller request failed: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service with pid 9615 named com.apple.DeviceActivityUI.DeviceActivityReportService.viewservice was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid." UserInfo={NSDebugDescription=The connection to service with pid 9615 named com.apple.DeviceActivityUI.DeviceActivityReportService.viewservice was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid.}
Hi everyone,
I am trying to change the settings when the shield button is clicked.
When I called let store = ManagedSettingsStore() in the ShieldAction extension, store.shield.applications is nil. How can I access the instance created in the host app?
Besides, has anyone ever tried to change the shield UI after clicking a button on the shield screen? I've searched around but no luck. is there any way I can notify the host app for further actions? Any help would be appreciated! Thank you very much.
Sorry I don't know why I can't add the wwdc21-10123 tag.
Post not yet marked as solved
Hi dear , I am a beginner developer
I have an application idea , and I think its great idea 😎
I think the application needs to use Device activity frame work , and UIScreen class , even if the app is in background or terminated , the problem is I don't know how to use these classes and frameworks 🤷🏻♂️
the questions are :
can I detect UITouch event on UIScreen object even if the app is in background or terminated
How to get the current activity name of the device
Hi all,
I am facing a problem following the code in the "Meet the Screen Time API" video. I've tried scheduling the monitoring time from
00:00 to 25:59 or some other time but functions in DeviceActivityMonitor are never being called.
I tried to print log from those functions, nothing shown. Is there any settings I've missed? In addition, I already changed the NSExtensionPrincipalClass value to my class name.
Any help would be appreciated!
Post not yet marked as solved
Hi everyone,
I am going to develop an app that manage a user's own app usage and activities. I know that there's a ScreenTime API but looks like it's for family control only. Is there any way that I can list app usages of my own device in my app?
Any answer will be appreciated. Thank you very much.
Post not yet marked as solved
Hi,
Has anyone managed to store applications, categories or webDomains from FamilyActivitySelection into UserDefaults ?
Application or Category is not Codable. How do we encode this into JSON?
Thanks for your help
Post not yet marked as solved
Using shared authorization I am able to authorize the child's device and able to see all the installed apps on the child's mobile on the parent device. But when I am trying to call DeviceActivity nothing happens. This is how I am calling DeviceActivity
override func intervalDidStart(for activity: DeviceActivityName) {
super.intervalDidStart(for: activity)
}
override func intervalDidEnd(for activity: DeviceActivityName) {
super.intervalDidEnd(for: activity)
}
override func eventDidReachThreshold(_ event:DeviceActivityEvent.Name,activity:DeviceActivityName){
super.eventDidReachThreshold(event, activity: activity)
}
}
info.plist
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.deviceactivity.monitor-extension</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).DeviceActivityMonitorExtension</string>
</dict>
Post not yet marked as solved
http://kzmcherry77@gmail.com
Support
linkText
Post not yet marked as solved
I'm wondering if anyone has an example of an implementation of the Screen Time API / DeviceActivity Framework. It's really hard to find any information about it, and seeing an example in practice would help me a lot.
Post not yet marked as solved
Does screen time api blocks an app if it is not available on the app store anymore but it is still installed on a child device?
Post not yet marked as solved
is blocking and shielding can be done when the case is 2 completely separate apps one for the parent and one for the child and not one app that have 2 types of users (parent and child)?
Post not yet marked as solved
Has anyone found a solution to this problem, knows what is the matter?
Grigoriy1960
Post not yet marked as solved
Several times over the last week, I've noticed a green dot when unlocking my phone. It goes away shortly after the unlock completes. I understand this means an app is using my camera while the device is locked. I've enabled app activity recording and inspected the logs following these instructions: https://developer.apple.com/documentation/network/privacy_management/inspecting_app_activity_data
Upon inspection, I'd expect to see an entry with "type": "access" somewhere but there are none. Everything recorded has the type networkAccess only.
Why am I seeing the green dot without any related access logs?
Post not yet marked as solved
I have created the app that uses Screen Time API (Device Activity, Managed Settings and Family Control). I have allowed on child device block and unblock apps that are selected in familyPicker, but I have to add ability to unblock these apps for some period of time. I have tried this:
do {
center.stopMonitoring()
try center.startMonitoring(.unblock, during: schedule, events: [.encouraged: DeviceActivityEvent(
applications: applications.applicationTokens,
threshold: DateComponents(second: 30)
)])
print("Unblock apps")
} catch {
print("Error")
}
Maybe I have to use another way to do it? but this doesn't work for me.