Plugin.Maui.Spine.BackgroundTasks
0.1.15
dotnet add package Plugin.Maui.Spine.BackgroundTasks --version 0.1.15
NuGet\Install-Package Plugin.Maui.Spine.BackgroundTasks -Version 0.1.15
<PackageReference Include="Plugin.Maui.Spine.BackgroundTasks" Version="0.1.15" />
<PackageVersion Include="Plugin.Maui.Spine.BackgroundTasks" Version="0.1.15" />
<PackageReference Include="Plugin.Maui.Spine.BackgroundTasks" />
paket add Plugin.Maui.Spine.BackgroundTasks --version 0.1.15
#r "nuget: Plugin.Maui.Spine.BackgroundTasks, 0.1.15"
#:package Plugin.Maui.Spine.BackgroundTasks@0.1.15
#addin nuget:?package=Plugin.Maui.Spine.BackgroundTasks&version=0.1.15
#tool nuget:?package=Plugin.Maui.Spine.BackgroundTasks&version=0.1.15
Plugin.Maui.Spine.BackgroundTasks
Background tasks for .NET MAUI: a class with [BackgroundTask] is found at startup, like a Spine page or widget, and run by the platform's scheduler while the app is not on screen. That is BGTaskScheduler on iOS and JobScheduler on Android. On Windows and Mac Catalyst a timer runs the tasks while the app is open. After a run, the widgets the task names are rebuilt, so a home-screen widget stays fresh without the app being opened.
dotnet add package Plugin.Maui.Spine.BackgroundTasks
builder.UseSpine(options => options.AddAssembly(typeof(MauiProgram).Assembly)); // registers BackgroundTasks too
// builder.UseSpineBackgroundTasks(o => o.Interval("standings", TimeSpan.FromHours(1))); // only to change the options
[BackgroundTask("standings", IntervalMinutes = 30, RequiresNetwork = true, Widgets = ["team"])]
public sealed class StandingsTask(IStandingsApi api, StandingsStore store) : IBackgroundTask
{
public async Task RunAsync(BackgroundTaskRun run, CancellationToken cancellationToken) =>
await store.SaveAsync(await api.FetchAsync(cancellationToken), cancellationToken);
}
await tasks.RequestAsync("standings"); // IBackgroundTasks: run it now
var status = tasks.StatusOf("standings"); // last run, outcome, error, next due
The platform decides when a scheduled task runs. iOS runs it when it chooses, never on a clock, and not after the user swipes the app away. Android runs it at most every 15 minutes. Windows and Mac Catalyst run it only while the app runs (IBackgroundTasks.RunsWhileClosed is false there).
On iOS the build adds UIBackgroundModes: fetch and one task identifier, <ApplicationId>.spine.refresh, to Info.plist. Spine runs every task under that one identifier, because iOS allows one pending refresh request per app. With Plugin.Maui.Spine.Widgets in the app, the widgets' background refresh runs as the built-in task spine.widgets.
Documentation
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-android36.0 is compatible. net10.0-ios26.0 is compatible. net10.0-maccatalyst26.0 is compatible. net10.0-windows10.0.19041 is compatible. |
-
net10.0-android36.0
- AsyncAwaitBestPractices (>= 10.0.0)
- Microsoft.Maui.Controls (>= 10.0.50)
- Plugin.Maui.Spine (>= 0.1.15)
- Plugin.Maui.Spine.Common (>= 0.1.15)
-
net10.0-ios26.0
- AsyncAwaitBestPractices (>= 10.0.0)
- Microsoft.Maui.Controls (>= 10.0.50)
- Plugin.Maui.Spine (>= 0.1.15)
- Plugin.Maui.Spine.Common (>= 0.1.15)
-
net10.0-maccatalyst26.0
- AsyncAwaitBestPractices (>= 10.0.0)
- Microsoft.Maui.Controls (>= 10.0.50)
- Plugin.Maui.Spine (>= 0.1.15)
- Plugin.Maui.Spine.Common (>= 0.1.15)
-
net10.0-windows10.0.19041
- AsyncAwaitBestPractices (>= 10.0.0)
- Microsoft.Maui.Controls (>= 10.0.50)
- Plugin.Maui.Spine (>= 0.1.15)
- Plugin.Maui.Spine.Common (>= 0.1.15)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.