Plugin.Maui.BackgroundTasks 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Plugin.Maui.BackgroundTasks --version 1.0.0
                    
NuGet\Install-Package Plugin.Maui.BackgroundTasks -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Plugin.Maui.BackgroundTasks" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Plugin.Maui.BackgroundTasks" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Plugin.Maui.BackgroundTasks" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Plugin.Maui.BackgroundTasks --version 1.0.0
                    
#r "nuget: Plugin.Maui.BackgroundTasks, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Plugin.Maui.BackgroundTasks@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Plugin.Maui.BackgroundTasks&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Plugin.Maui.BackgroundTasks&version=1.0.0
                    
Install as a Cake Tool

Plugin.Maui.BackgroundTasks

NuGet

A .NET MAUI plugin that gives Android and iOS a single API for scheduling background work.

  • One-time and periodic tasks
  • Shared constraints (network, charging, battery)
  • Registered handlers that run when the OS launches the work
  • Optional logging and execution events
  • In-process RunNowAsync for tests and demos

Android uses JobScheduler. iOS uses BGTaskScheduler (BGAppRefreshTask / BGProcessingTask).

Install

dotnet add package Plugin.Maui.BackgroundTasks

Or reference the project:

<ProjectReference Include="..\src\Plugin.Maui.BackgroundTasks\Plugin.Maui.BackgroundTasks.csproj" />

Register the plugin

builder
    .UseMauiApp<App>()
    .UseBackgroundTasks(options =>
    {
        options.EnableLogging = true;
        options.Register<SyncTask>("com.example.app.sync");
        options.Register<CleanupTask>("com.example.app.cleanup");
    });

Resolve IBackgroundTaskScheduler from dependency injection, or use BackgroundTasks.Current.

Define a task

public sealed class SyncTask : IBackgroundTask
{
    public async Task<BackgroundTaskResult> RunAsync(
        BackgroundTaskContext context,
        CancellationToken cancellationToken)
    {
        // Keep iOS refresh work short. The OS can expire the task.
        await SyncAsync(context.Parameters, cancellationToken);
        return BackgroundTaskResult.Success;
    }
}

Return Retry when the work should be attempted again (honored by Android JobScheduler).

Schedule work

var scheduler = BackgroundTasks.Current;

await scheduler.ScheduleAsync(new BackgroundTaskRequest
{
    TaskId = "com.example.app.sync",
    Delay = TimeSpan.FromMinutes(5),
    Kind = BackgroundTaskKind.Refresh,
    Constraints = new BackgroundTaskConstraints
    {
        RequiresNetwork = true,
        RequiresBatteryNotLow = true
    }
});

await scheduler.SchedulePeriodicAsync(new PeriodicBackgroundTaskRequest
{
    TaskId = "com.example.app.sync",
    Interval = TimeSpan.FromMinutes(15),
    Kind = BackgroundTaskKind.Refresh,
    Constraints = new BackgroundTaskConstraints { RequiresNetwork = true }
});

Cancel, inspect, or run immediately:

await scheduler.CancelAsync("com.example.app.sync");
var scheduled = await scheduler.GetScheduledTasksAsync();
var result = await scheduler.RunNowAsync("com.example.app.sync");

Host app setup

Android

The package declares WAKE_LOCK, RECEIVE_BOOT_COMPLETED, and ACCESS_NETWORK_STATE, and registers a JobService. Jobs persist across process death and reboots.

No extra manifest identifiers are required. Use reverse-DNS task ids so they stay unique across the app.

iOS

Declare background modes and every task identifier in Platforms/iOS/Info.plist:

<key>UIBackgroundModes</key>
<array>
    <string>fetch</string>
    <string>processing</string>
</array>
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
    <string>com.example.app.sync</string>
    <string>com.example.app.cleanup</string>
</array>

UseBackgroundTasks registers BGTaskScheduler handlers during MAUI startup (inside FinishedLaunching). Identifiers that are missing from Info.plist will fail at schedule time with a clear error.

Because the plugin stores schedules in Preferences, add the User Defaults reason to the iOS privacy manifest if you have not already:

<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>

Testing iOS tasks

iOS decides when refresh and processing tasks actually run. In the Xcode debugger you can force a launch:

e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.example.app.sync"]

If the user force-quits the app, iOS will not launch scheduled background tasks until the user opens the app again.

Platform notes

Android iOS
Native API JobScheduler BGTaskScheduler
Periodic minimum 15 minutes (clamped) Requested interval is an earliest-begin hint
Survives process death Yes Yes, unless the user force-quits
Survives reboot Yes The plugin resubmits when the app launches or backgrounds
Exact timing Not guaranteed Not guaranteed

net10.0 is included so shared code can reference the package. Scheduling APIs throw BackgroundTaskException (FeatureNotSupported) on that target. RunNowAsync still executes registered handlers.

This plugin is for deferrable work. Long-running, user-visible operations (music, navigation, large uploads) still need a host-app Android foreground service and the matching iOS background mode.

Sample

samples/BackgroundTasks.Sample schedules, cancels, and runs the sample refresh/processing handlers.

dotnet build src/Plugin.Maui.BackgroundTasks/Plugin.Maui.BackgroundTasks.csproj
dotnet pack src/Plugin.Maui.BackgroundTasks/Plugin.Maui.BackgroundTasks.csproj -c Release
dotnet build samples/BackgroundTasks.Sample/BackgroundTasks.Sample.csproj -f net10.0-android

Pack

dotnet pack src/Plugin.Maui.BackgroundTasks/Plugin.Maui.BackgroundTasks.csproj -c Release

Packages are written to artifacts/.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-android36.0 is compatible.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-ios26.0 is compatible.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Plugin.Maui.BackgroundTasks:

Package Downloads
Plugin.Maui.Observability

Umbrella telemetry pipeline for .NET MAUI on iOS and Android. Unifies AppHealth, NetworkMonitor, ApiResilience, BackgroundTasks, OfflineSync, SmartUpload, and DeviceSession into one signal stream, and exports to OpenTelemetry, Application Insights, Sentry, Datadog, Console, or a custom HTTP endpoint.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 87 9/2/2026
1.0.5 103 8/30/2026
1.0.4 94 8/30/2026
1.0.3 95 8/28/2026
1.0.2 93 8/28/2026
1.0.1 97 8/28/2026
1.0.0 95 8/27/2026

Initial release: unified one-time and periodic background tasks for Android JobScheduler and iOS BGTaskScheduler.