Situation: I have a Blazor Web Assembly that makes an API call every 10 seconds and evaluates this call. This evaluation and request is carried out within a tab and a PWA (depending on the user).
Requirement: The Web Assembly should continue to run in the background on Android and IOS devices Desktop will be added later
Problem: A PWA cannot run in the background on Android and IOS; the OS itself prohibits it or pauses the process until it is in the foreground again.
My idea was to convert the project into an app using a wrapper such as Cordova or Capacitor, but this seems to clash with the Blazor framework and the project structure. Have you had any experience with this or have any other ideas?
I tried to give my PWA permissions to enable it to work in the background
I used several APIs, including one that reads the location every X amount of time
I tried to create a wrapper for my Blazor application using Cordova and Capacitor
I used several experimental branches of .Net, including Blazor Binding
You can't on Android. The OS is explicitly designed to not let apps run indefinitely in the background. Definitely not at the rate of every 10 seconds. Doing that would absolutely murder the battery. The right solution here is not to poll an API, but to rewrite your infrastructure to send a push notification when new data is available.