SwiftBindings.Apple.ActivityKit 26.2.6

dotnet add package SwiftBindings.Apple.ActivityKit --version 26.2.6
                    
NuGet\Install-Package SwiftBindings.Apple.ActivityKit -Version 26.2.6
                    
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="SwiftBindings.Apple.ActivityKit" Version="26.2.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SwiftBindings.Apple.ActivityKit" Version="26.2.6" />
                    
Directory.Packages.props
<PackageReference Include="SwiftBindings.Apple.ActivityKit" />
                    
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 SwiftBindings.Apple.ActivityKit --version 26.2.6
                    
#r "nuget: SwiftBindings.Apple.ActivityKit, 26.2.6"
                    
#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 SwiftBindings.Apple.ActivityKit@26.2.6
                    
#: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=SwiftBindings.Apple.ActivityKit&version=26.2.6
                    
Install as a Cake Addin
#tool nuget:?package=SwiftBindings.Apple.ActivityKit&version=26.2.6
                    
Install as a Cake Tool

SwiftBindings.Apple.ActivityKit

Native .NET bindings for Apple's ActivityKit framework — the API behind Live Activities and the Dynamic Island on iOS.

You can start, update, and end Live Activities from C#. The request/update/end chain is verified end-to-end on both the iOS Simulator (Mono JIT) and a physical device (NativeAOT).

Quick start

dotnet add package SwiftBindings.Apple.ActivityKit

The content crosses as a JSON string, but you never hand-write it — model each payload as a C# type and serialize it (camelCase keys match the Swift struct your widget decodes into). Your payload shape and your widget's UI are entirely yours:

using System.Text.Json;
using System.Text.Json.Serialization;
using Swift.ActivityKit;

record DeliveryAttributes(string OrderId);
record DeliveryState(string Status, string? Eta = null);

var jsonOptions = new JsonSerializerOptions
{
    PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
    DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
};

if (LiveActivity.AreActivitiesEnabled)
{
    var activity = LiveActivity.Request(
        name: "delivery",
        attributesJson:   JsonSerializer.Serialize(new DeliveryAttributes("A-42"), jsonOptions),
        contentStateJson: JsonSerializer.Serialize(new DeliveryState("Preparing", "15 min"), jsonOptions));

    activity.Update(JsonSerializer.Serialize(new DeliveryState("Out for delivery", "5 min"), jsonOptions));
    activity.End(JsonSerializer.Serialize(new DeliveryState("Delivered"), jsonOptions), immediate: true);
}

Publishing to a physical device (NativeAOT)? Reflection-based serialization warns there; the wiki guide shows the source-generated variant for a warning-free publish.

Two more things are required, both standard for any Live Activity (Swift apps need them too):

  1. Add <key>NSSupportsLiveActivities</key><true/> to your app's Info.plist.
  2. Embed a small SwiftUI widget extension (~30 lines) to render the activity.

The complete walkthrough — the widget template, the shared attributes type, and the full C# API — is in the wiki:

➡️ Live Activities from .NET

How it works

ActivityKit's entry point is Activity<Attributes>, where Attributes conforms to ActivityAttributes: Codable & Hashable. Those conformances are synthesized by the Swift compiler from the type's stored properties at compile time — so a C# type the Swift compiler never saw cannot serve as Attributes, and Activity<YourCSharpType> can never be materialized from C#.

This binding sidesteps that by shipping one fixed, Swift-defined attributes type (DotNetLiveActivityAttributes) inside the native SBApple framework. Because it is concrete at the binding's build time, the compiler synthesizes its witnesses then, and the Activity<…> generic is resolved entirely within SBApple — no generic and no protocol-witness table ever crosses the C ABI. Your per-activity data rides inside that fixed type as JSON; the widget decodes it to draw the UI.

Cross-process pairing between your running activity and the widget is by the attributes type's unqualified name plus a Codable round-trip, so your widget extension declares its own byte-for-byte copy of the type (Apple's standard "attributes in two targets" pattern) and never links this package.

What ships vs. what doesn't

Ships and works:

  • LiveActivity.Request / Update / End — the full lifecycle, returning a handle.
  • LiveActivity.AreActivitiesEnabled, IsActive, and LiveActivityException for the failure reason.
  • LiveActivity.ObservePushToken — APNs push tokens for server-driven updates (lowercase hex), when started with usePushToken: true.
  • Registry hardening: idempotent End, and Update-after-End is a safe no-op rather than a use-after-free.

Not available: genuinely distinct, strongly-typed ActivityAttributes structs authored per app in C#. You model per-activity data as JSON inside the one fixed type instead. If you need separate compiler-checked attributes types, declare them in a Swift companion target and call into a narrow @_cdecl shim — the same technique this binding uses internally.

Documentation

Product Compatible and additional computed target framework versions.
.NET net10.0-ios26.2 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
26.2.6 33 6/11/2026