-
Notifications
You must be signed in to change notification settings - Fork 500
Please support Background task! #409
Comments
Can you describe more as to what you mean here. |
Sorry for my bad English. |
Do you have an example of the APIs on each platform you are looking to have abstracted? |
Example I want to send a GET method to get news every 15 min without open app! |
Andriod new component for this is the Android WorkManager api - doesn't seem like Xamarin supports this yet. But it would be great to have a scheduler for both platforms supported on Essentials |
I strongly support this proposal. We needed this for several apps and always rolled our own implementation, which always added overhead until you got everything right. Scheduling actions is very platform specific, and there is a huge potential for miususe. I.E. iOS, if you take a look at the docs you can see that for apps that need to update from time to time as i guess @nguyenthanhliemfc has to do you can see that it states
Android is a lot more liberal with its Job scheduler (docs). It can specify a deadline, indicate that the job is to be persisted across reboots etc. It is available from Android 5.0 onward, for 4.4 we would have to look at the Alarm Service. This is also more permissive than iOS, thus we would still be limited by iOS. Finally, UWP is also mightier that iOS in that regard (docs). You have certain restrictions such as the minimum interval allowed between internally triggered background events is 15 minutes, and that your app only has 30 seconds to process your tasks. In conclusion, the only common api I would feel comfortable to expose without overpromising is something like this: public static class Scheduler |
In my company have Server and Client app. My boss assigns the job to the employee on Server |
I'll add a +1 and a use case to this. One example that comes up a lot is long-running tasks. For example, we had a phonebook app that, because of Reasons(tm) needed to do a large fetch of the latest phonebook on startup. Being able to reliably do this in the background would have been excellent. As it was, we had to do it in the foreground, and hope we were lucky enough that the user didn't switch away during the download. So perhaps there are two cases here:
|
+1 Vote |
+1 |
I saw this: https://github.com/aritchie/jobs |
This is a good idea, I just need this functionality. In my application, I need to periodically do synchronization with the server, so as in the project that showed @mattleibow, it would be nice to do Backround Task that are inherited from the interface. We can place or delete them from the container of active tasks, and thus get control over the tasks. for example, when an application goes into sleep mode or is terminated, we can put the necessary task in the container. and when the application returns to its working state, take it back. |
One moment is Apple's permission. They have a list of allowed actions in Background mode. We need to make sure that Apple will allow the publication of the application. |
Relevant link for anyone looking for more info on this |
+1 |
While this is in our backlog for a feature request I would recommend checking out the excellent Shiny project: https://github.com/shinyorg/shiny |
@jamesmontemagno ...background task is all ok. ...HOW TO USE XAMARIN ESSENTIALS IN FOREGROUND OR BACKGROUND SERVICE IN ANDROID WHICH NEEDS TO RUN EVEN HEN APP UI CLOSES? How can we init the Xamarin.Essentials.Platform.Init? OR is there some workaround? Android background or foreground service doesn't have needed params to initialize that xamarin essentials dll. THIS BLOCKS ALL FEATURES OF XAMARIN ESSENTIALS TO BE USED IN A BACKGROUND OR FOREGROUND SERVICE. NOTE: service is backbone architecture of worthy android apps, rest is all for amateurs. TO BE SPECIFIC: |
Do you have try MessageCenter to call it from Service class? |
Also bump from 1.5.9999 to 1.5.99999 to distinguish if it includes background task support. Fixes xamarin#409
Also bump from 1.5.9999 to 1.5.99999 to distinguish if it includes background task support. Fixes xamarin#409
Also bump from 1.5.9999 to 1.5.99999 to distinguish if it includes background task support. Fixes xamarin#409
Also bump from 1.5.9999 to 1.5.99999 to distinguish if it includes background task support. Fixes xamarin#409
Also bump from 1.5.9999 to 1.5.99999 to distinguish if it includes background task support. Fixes xamarin#409
Did it make it through? I need to periodically send information to my server all day long from an android device. |
I need this functionality as well. |
Also bump from 1.5.9999 to 1.5.99999 to distinguish if it includes background task support. Fixes xamarin#409
Hey @Rothanan, @linda-dge (and others), my team and I have proposed a PR: #1674 . Can you help us add Samples, documentation and test it? Thanks! |
Thanks everyone for the input here! We won't be doing this for Xamarin.Essentials anymore. I highly recommend you look at Shiny a library that does this very well. Background tasks have a lot of considerations. We are definitely willing to consider this for .NET MAUI but I would like to ask you that if you open an issue or discussion to add a lot of detail on how you would like to use it. Without it, it will be pretty hard to make a plan for it. Again, thanks and hopefully we can get this in .NET MAUI at some point in time! |
Fixes xamarin#409 Upstream PR: xamarin#1674
Fixes xamarin#409 Upstream PR: xamarin#1674 (Removed .netstandard1.0 target framework because it doesn't support OS checks.) Co-authored-by: Taras <mail@webwarrior.ws>
Fixes xamarin#409 Upstream PR: xamarin#1674 (Removed .netstandard1.0 target framework because it doesn't support OS checks.) Co-authored-by: Taras <mail@webwarrior.ws>
Fixes xamarin#409 Upstream PR: xamarin#1674 (Removed .netstandard1.0 target framework because it doesn't support OS checks.) Co-authored-by: Taras <mail@webwarrior.ws>
Fixes xamarin#409 Upstream PR: xamarin#1674 (Removed .netstandard1.0 target framework because it doesn't support OS checks.) Co-authored-by: Taras <mail@webwarrior.ws>
Thank you for Essentials. It's help me a lot in development app
It will be nice if support Background Task!
Thank you!
The text was updated successfully, but these errors were encountered: