How to get the bundleIdentifier or app name from FamilyActivitySelection's applicationTokens?

I'm working with the FamilyControls and DeviceActivity frameworks in iOS (Swift).

In my app, I collect selected apps using a FamilyActivitySelection, and I access the selected apps via selection.applicationTokens, which gives me a Set<ApplicationToken>.

I would like to get either the bundle identifier or the display name of the selected apps from these ApplicationTokens.

I tried creating an Application instance using:

let app = Application(token: token)
print(app.bundleIdentifier)
print(app.localizedDisplayName)
However, both bundleIdentifier and localizedDisplayName are always nil.

My questions are:

Outside the extension (in the main app), how can I get the bundleIdentifier or display name from an ApplicationToken?

Is there an Apple-recommended way to resolve a Token<Application> into something human-readable or usable?

If not, what is the best practice to store or identify user-selected apps for later use?

Environment: iOS 17, Swift 5, Using FamilyControls and DeviceActivity APIs.

Thank you for any help!

It's my understanding that you aren't allowed/supposed to rehydrate the app selection tokens that you get from the FamilyActivitySelection. However, apps like Opal show a bundle identifier or display name after the fact, so I guess you are allowed to do it?

If you come across how to do it, I would also like to know. Might be a screenshot that is sent to a server that recognizes the apps from the image and then stores them for later use?

You can pass any of the tokens to the SwiftUI Label constructor to show the app name and/or icon.

How to get the bundleIdentifier or app name from FamilyActivitySelection's applicationTokens?
 
 
Q