fluttercommunity / flutter_workmanager

A Flutter plugin which allows you to execute code in the background on Android and iOS.
851 stars 260 forks source link

How to test BGTaskScheduler on Flutter? #512

Open nicolobozzato opened 11 months ago

nicolobozzato commented 11 months ago

I read the IOS setup very carefully and I would like to test my implementation. So I arrived at this point Testing BGTaskScheduler and I read the instruction on apple website https://developer.apple.com/documentation/backgroundtasks/starting_and_terminating_tasks_during_development

The first point say Set a breakpoint in the code that executes after a successful call to [submit(_:)](https://developer.apple.com/documentation/backgroundtasks/bgtaskscheduler/3142252-submit).

How is it possible to do that in flutter? it seems to me that I can run the subsequent command e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"TASK_IDENTIFIER"] only in Xcode, but how can I put a breakpoint on the code that run after a successful call to [submit(:)]_ ?

Thank you

sotomski commented 11 months ago

You can simply pause the app execution in Xcode's debugger, pass the command, wait for debugger's confirmation and resume the app. The task will be executed.