.net MAUI background service.

Heinz Deubler 181 Reputation points
2023-02-22T18:58:56.8866667+00:00

I am currently working on a project where the users has to input data, sometimes in an area where there is no cell reception or WIFI. In the case of no cell reception the data will be saved to a SQLIte db on the device. Once the user has cell reception again the data will be uploaded to a SQL db via a REST api.

So I am looking for a way for the app to keep on running in the background till the user has cell reception again and the data can be uploaded. I hope this makes sense.

Developer technologies | .NET | .NET MAUI
Developer technologies | .NET | Other
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2023-02-28T06:44:23.8133333+00:00

    Hello,

    So I am looking for a way for the app to keep on running in the background till the user has cell reception again and the data can be uploaded. I hope this makes sense.

    For how to use the background service in MAUI you can refer to the following documentation, although they are Xamarin documentation, but still available in MAUI.

    For Android: Foreground Services.

    On Android platform, the foreground service has a higher priority than the ordinary background service, which can be more effectively kept alive.

    For iOS: iOS Backgrounding with Tasks.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Alessandro Caliaro 4,196 Reputation points
    2023-02-22T21:08:15.8433333+00:00

    It’s hard to have an app working in background because the OS could kill it. In Android you could use a foreground service that is never killed by the OS. In iOS, maybe there is something similar. Otherwise you could send data when the app turn to foreground and the connection is working

    3 people found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.