How can I count the number of pickups for a certain application?
The docs say that there is a struct ApplicationActivity within the DeviceActivityData: https://developer.apple.com/documentation/deviceactivity/deviceactivitydata
Using this code I receive a warning in XCode: Value of type 'DeviceActivityData' has no member 'applicationActivity'
struct ApplicationPickupCountReport: DeviceActivityReportScene {
// Define which context your scene will represent.
let context: DeviceActivityReport.Context = .applicationPickupCount
// Define the custom configuration and the resulting view for this report.
let content: (String) -> ApplicationPickupCountView
func makeConfiguration(representing data:
DeviceActivityResults<DeviceActivityData>) async -> String {
var totalPickups = 0
let totalPickups = await data.flatMap { $0.applicationActivity }.reduce(0, {
$0 + $1.numberOfPickups
})
return "\(totalPickups)"
}
}