Hey there,
I wanted to use this to create a background task for my MacOS App.
Unfortunately I don't knwo how to insert the code.
I created
let activity = NSBackgroundActivityScheduler(identifier: "com.example.MyApp.work")
in AppDelegate and insert
activity.repeats = true
activity.interval = 30
in applicationDidFinishLaunching() to initialize the values.
But where is the right place to insert
activity.schedule() { (completion: NSBackgroundActivityScheduler.CompletionHandler) in
// Perform the activity
print("Hello World")
self.completion(NSBackgroundActivityScheduler.Result.Finished)
}
in that way that this application will get a background task, which is not stopped if I quit (or leave) the application?
Maybe that's an sutpid question but if so it sould be easy to answer ;-)
Thanks a lot!