This is a sample code demonstrating how to use Apple's Background Tasks for iOS 15, Swift 5 and SwiftUI.
How to run this code.
-
Clone project.
-
Start project with your physical device. (Do not use simulator!)
-
When running, click pause.
-
Run in your Xcode's terminal:
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.mikasoftware.BGTaskSample.Refresh"]
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.mikasoftware.BGTaskSample.Processing"]
-
Resume your code.
-
You should see message in your terminal:
Text: Hello world!
Text: Hello world! v2
- Enjoy!