Family Activity Picker | Screen Time API features iOS 16

Hi all!

Is it possible to retrieve detailed data of applications from opaque token which we receive from FamilyActivityPicker?

If no, is it possible retrieve application info especially icon from applications that were selected in FamilyActivityPicker?

Thank you!

Replies

You can use a Label to display the icon and name of apps selected in a FamilyActivityPicker: https://developer.apple.com/documentation/familycontrols/displayingactivitylabels

Alternatively, it is also possible to display the localized names and bundle identifiers (as well as usage data) for apps selected by the user in a FamilyActivityPicker by creating a Device Activity report app extension and then displaying a DeviceActivityReport with a filter containing the desired tokens.

Hey once again, Kmart :)

Thank you for the answer! I've tried both variants, and both lead to issues...

Is the Documentation up to date?

Have I been doing something wrong?

Hi, the same issue. Please let us know what is wrong.

Thanks in advance!

Yes, the documentation is incorrect here. The Label should be given an actual ApplicationToken, not a binding to it (the "$" character at the start of the parameter). The following would fix the compilation error:

    Label(selection.applicationTokens.first!) // <-- compiles, but not useful

but that code isn't really usable, since it would crash if the selection doesn't have any application tokens. An alternative is something like this:

    if let applicationToken = model.selectionToDiscourage.applicationTokens.first {
        Label(applicationToken)
    }
    else {
        Label("No application", systemImage: "app.dashed")
    }

In my case Label(selection.applicationTokens.first!) is not showing, what is the problem?

if selection.applicationTokens.count != 0 {
                    Label(selection.applicationTokens.first!)
                } else {
                    Label("No application", systemImage: "app.dashed")
                }
                FamilyActivityPicker(selection: $selection)