I used User Defaults.
Post
Replies
Boosts
Views
Activity
create a new extension (i chose call directory extension but maybe at the time you read this there will be an extension for activity monitor)
int the info pList of the extension set the NSExtensionPointIdentifier key to be com.apple.deviceactivity.monitor-extension
go to the swift file that was created (will be called CallDirectoryHandler if you chose a call directory extension ) and make it implement the
DeviceActivityMonitor protocol
you can change the name of this class if you want
set the NSExtensionPrincipalClass inside the pList to the name of the class that implementing DeviceActivityMonitor protocol
add the override methods you want (the most relevant ones are: intervalDidEnd and intervalDidStart. see example at the end of the message)
call the DeviceActivityCenter start monitor on you APP Not the Extension with the needed parameter (you can see that on the tutorial of this api)
example overridden methods:
override func intervalDidStart(for activity: DeviceActivityName) {
super.intervalDidStart(for: activity)
}
override func intervalDidEnd(for activity: DeviceActivityName) {
super.intervalDidEnd(for: activity)
}
thank you very much!
i thought that there is another way to share data between app and an app extension i guess i was wrong
did all of the above and still none of the methods on MyDeviceActivityMonitor gets called.
i'm using the monitor.startMonitoring() method and nothing appends
thank you!