Open walsha2 opened 3 years ago
Hi @walsha2 & thank you for the issue. You raise many interesting points.
On BGProcessingTask
vs BGAppRefreshTask
:
.registerOneOffTask
task and pass a parameter.About "Continuous Scheduling":
initialize
). When the work within that task requires other tasks, it should be straightforward to schedule from there. What do you think?Hello are you interested in any help on this matter ? I'm willing to help in order to have a registerPeriodicTask
working in iOS, seem like we could definitly use BGAppRefreshTask althought frequency will not be guaranteed.
Cheers
@jocelyngriselle that would be awesome! 1 other question: is there a guarantee, that the BGAppRefreshTask runs let say daily, if the app was not open a longer time (on iOS 13)?
Hi @walsha2 & thank you for the issue. You raise many interesting points.
On
BGProcessingTask
vsBGAppRefreshTask
:
- I was not aware at the time of the differences and the impact on the scheduler for these. This should definitely be a improvement to the plugin. I think it can be addressed by extending the
.registerOneOffTask
task and pass a parameter.About "Continuous Scheduling":
- Hm, I am not fully sure about that one. I thought that we could schedule further tasks from within the Workmanager dispatcher (registered via
initialize
). When the work within that task requires other tasks, it should be straightforward to schedule from there. What do you think?
Hi, is there a plan to implement this please? That is to be able to submit to the BGTaskScheduler both a BGAppRefreshTaskRequest & BGProcessingTaskRequest.
@ened can you please update us on the the issue @walsha2 were you able to find a solution for BGAppRefreshTask @jocelyngriselle were you able to fork or create another solution for iOS period tasks and BGAppRefreshTask
Hi @ened I've been working on improving iOS side to incorporate BGAppRefreshTask, one off immediate tasks, and processing tasks, and improving iOS docs, if you are not planning on this issue, it would be nice to collaborate and merge into workmanager, since iOS side of this plugin is lacking too much compared to Android. So far looks like I will be able to finish this week
@absar please open the PR so I can start taking a look. I was working on macOS next and want to prevent merge conflicts.
@ened I have been reviewing the work completed in #243 and working with the latest version of this package that includes those changes. I have some comments and questions that warranted a new issue and discussion, summarized here.
BGProcessingTask
vsBGAppRefreshTask
Is there a reason that this was implemented entirely as a
BGProcessingTaskRequest
? Is there any plan to allow for this request to be aBGAppRefreshTaskRequest
to handle smaller, more bite size operations?BGProcessingTaskRequest
is intended for tasks that take "minutes" and is overkill for more trivial background tasks. It may be detrimental to iOS scheduling to use this request type when it is not necessary.I am not sure if iOS has greater restrictions on the number of times
BGProcessingTask
can be executed vsBGAppRefreshTask
. I assume thatBGAppRefreshTask
can be executed and scheduled more often per iOS guidelines. I am trying to use this in order to perform home screen widget background refresh tasks and these are fairly lightweight operations so it makes more sense to use aBGAppRefreshTaskRequest
and not get penalized by the iOS scheduler.Continuous Scheduling
Second, it does not seem like there is a way to schedule these operations in a continuous manner. This is actually the purpose of
BGAppRefreshTask
and this is clearly displayed by Apple in the following link and code example, by Apple:https://developer.apple.com/documentation/backgroundtasks/refreshing_and_maintaining_your_app_using_background_tasks
If you download that code example you will see the following:
Then later on:
Do you notice how
handleAppRefresh()
callsscheduleAppRefresh()
so that this task can be continuously scheduled?This is perfect for things like home screen widgets and the purpose ofBGProcessingTask
. Right now, there are two limitations withflutter_workmanager
:BGAppRefreshTask
SwiftWorkmanagerPlugin
Even if I wanted to use
BGProcessingTask
(as it is currently implemented),SwiftWorkmanagerPlugin
does not expose a hook in theSwiftWorkmanagerPlugin.handle()
method to kick off another scheduled task after the current task completes.Discussion
Please let me know if that makes sense or if you have any questions! I think this would be great capability to add and is inline with how iOS intends
BGTaskScheduler
to be used. Look forward to discussing further!