@capgo/capacitor-widget-kit

June 26, 2026 · View on GitHub

Capgo - Instant updates for Capacitor

➡️ Get Instant updates for your App with Capgo

Missing a feature? We’ll build the plugin for you 💪

Create Home Screen WidgetKit, ActivityKit, and Android widget experiences from Capacitor without forcing one rendering model.

Demo

Demo of capacitor-widget-kit in action

Widget Screenshots

iOS Lock Screen Live Activity widget screenshot
iOS Lock Screen / Live Activity
iOS Dynamic Island widget screenshot
iOS Dynamic Island

The plugin has two implementation paths:

  • SVG template widgets: store Home Screen, Lock Screen, Dynamic Island, and Android layouts with optional named frames, hotspots, declarative state patches, pause/resume timers, and interaction events. Use this when your widget can be driven by resolved SVG output.
  • Full-native widget sessions: store shared JSON state for native widget code and queue app-to-widget or widget-to-app messages. Use this when you want to render the widget fully in Swift/Kotlin/Java but still need Capacitor to start, stop, sync, or process async work.

The included workout flow is only an example helper built on top of the generic SVG abstraction.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-widget-kit` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

bun add file:../capacitor-widget-kit
bunx cap sync ios
bunx cap sync android

iOS Requirements

  • Add a Widget Extension target for Home Screen / SpringBoard widgets.
  • iOS 17+ is recommended for interactive Home Screen widget and Live Activity buttons.
  • Add NSSupportsLiveActivities to the app Info.plist when using ActivityKit.
  • Add the same App Group to the app target and the widget extension target.
  • Set CapgoWidgetKitAppGroup in both Info.plist files to the shared App Group identifier.

Example App Group:

<key>CapgoWidgetKitAppGroup</key>
<string>group.app.capgo.widgetkit.exampleapp.widgetkit</string>

Native Widget Code

The plugin ships the native pieces a widget extension or Android widget can use:

  • CapgoTemplateActivityAttributes for the iOS Live Activity bridge
  • CapgoTemplateActionIntent for interactive iOS template buttons
  • CapgoTemplateWidgetTimelineProvider and CapgoTemplateHomeWidgetView for real iOS Home Screen / SpringBoard widgets backed by WidgetKit timelines
  • CapgoTemplateWidgetBridge to load a stored SVG activity and resolve one surface into svg + width/height + frameId + hotspots + metadata
  • CapgoTemplateSurfaceView, CapgoTemplateWidgetSurface, and CapgoTemplateLatestWidgetSurface to place a rendered SVG view under native hotspot buttons in SwiftUI
  • CapgoNativeWidgetBridge to load full-native widget sessions and exchange async messages without using SVG templates
  • CapgoTemplateActionReceiver and CapgoTemplateWidgetBridge for Android template widgets

In your iOS widget extension bundle:

import ActivityKit
import SwiftUI
import WidgetKit
import CapgoWidgetKitShared

@main
struct ExampleWidgetBundle: WidgetBundle {
    var body: some Widget {
        ExampleTemplateHomeWidget()

        if #available(iOS 16.2, *) {
            ExampleTemplateLiveActivityWidget()
        }
    }
}

struct ExampleTemplateHomeWidget: Widget {
    private let kind = "ExampleTemplateHomeWidget"

    var body: some WidgetConfiguration {
        StaticConfiguration(kind: kind, provider: CapgoTemplateWidgetTimelineProvider()) { entry in
            CapgoTemplateHomeWidgetView(entry: entry) { layout in
                MySvgRenderer(svg: layout.svg)
            } placeholder: {
                Text("No active widget")
            }
        }
        .configurationDisplayName("Capgo Template")
        .description("Home Screen widget rendered from the shared Capgo SVG template store.")
        .supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
    }
}

Use the SwiftUI surface helpers when a custom WidgetKit view should be designed from JS but rendered by native widget code:

CapgoTemplateLatestWidgetSurface {
    layout in
    MySvgRenderer(svg: layout.svg)
} placeholder: {
    Text("No active widget")
}

The helper positions CapgoTemplateActionIntent buttons over the resolved SVG hotspots on iOS 17+. See example-app/widget-extension/ExampleWidgetBundle.swift for a complete Home Screen widget and Live Activity scaffold.

SVG Template Usage

This mode is for Home Screen, Lock Screen, Dynamic Island, and Android widgets that can render resolved SVG. Hotspot actions can switch frames, mutate state, pause/play timers, and emit events for the app to process later.

import { CapgoWidgetKit } from '@capgo/capacitor-widget-kit';

const { activity } = await CapgoWidgetKit.startTemplateWidget({
  activityId: 'session-1',
  openUrl: 'widgetkitdemo://session/session-1',
  state: {
    title: 'Chest Day',
    frame: 'summary',
    restDurationMs: 90000,
  },
  definition: {
    id: 'generic-session-card',
    timers: [{ id: 'rest', durationPath: 'state.restDurationMs' }],
    actions: [
      {
        id: 'next-frame',
        eventName: 'widget.frame.changed',
        frameMutations: [{ op: 'next', path: 'frame', surface: 'homeScreen' }],
      },
      {
        id: 'toggle-rest',
        eventName: 'widget.timer.toggled',
        timerMutations: [{ op: 'toggle', timerId: 'rest' }],
      },
    ],
    layouts: {
      homeScreen: {
        width: 100,
        height: 40,
        frameIdPath: 'state.frame',
        frames: [
          {
            id: 'summary',
            hotspots: [{ id: 'switch', actionId: 'next-frame', x: 0, y: 0, width: 100, height: 40 }],
            svg: `<svg viewBox="0 0 100 40"><text x="6" y="20">{{state.title}}</text></svg>`,
          },
          {
            id: 'timer',
            hotspots: [{ id: 'pause-play', actionId: 'toggle-rest', x: 0, y: 0, width: 100, height: 40 }],
            svg: `<svg viewBox="0 0 100 40"><text x="6" y="20">{{timers.rest.remainingText}}</text></svg>`,
          },
        ],
      },
    },
  },
});

await CapgoWidgetKit.performTemplateAction({
  activityId: activity.activityId,
  actionId: 'toggle-rest',
  sourceId: 'app-pause-play-button',
});

const pendingEvents = await CapgoWidgetKit.listTemplateEvents({
  activityId: activity.activityId,
  unacknowledgedOnly: true,
});

Full-Native Widget Usage

This mode is for widgets rendered in native code. The app keeps a shared session state for sync reads/writes, and messages cover async jobs that need a later response.

const { session } = await CapgoWidgetKit.startWidgetSession({
  widgetId: 'native-session-1',
  kind: 'workout-controls',
  state: { isRunning: true, selectedSetId: 'set-1' },
  metadata: { accent: '#00d69c' },
});

await CapgoWidgetKit.updateWidgetSession({
  widgetId: session.widgetId,
  merge: true,
  state: { isRunning: false },
});

const { message } = await CapgoWidgetKit.sendWidgetMessage({
  widgetId: session.widgetId,
  direction: 'widgetToApp',
  name: 'syncWorkoutSet',
  payload: { setId: 'set-1' },
  expectsResponse: true,
});

await CapgoWidgetKit.completeWidgetMessage({
  messageId: message.messageId,
  response: { synced: true },
});

await CapgoWidgetKit.stopWidgetSession({ widgetId: session.widgetId });

Example App

The example-app/ folder is a lightweight Vite demo for the generic template flow. It runs in the browser using the preview store and demonstrates:

  • starting one SVG template widget for the Home Screen surface
  • resolving the Home Screen surface
  • running an action from the app and from a hotspot overlay
  • reading the stored widget template back
  • reading and acknowledging the event log
  • ending the stored template

The workout helper is only used there as an example template factory.

API

Capacitor bridge for an iOS-first WidgetKit / Live Activities plugin.

The core abstraction is a generic SVG template record:

  • raw SVG templates with binding placeholders
  • declarative action patches
  • timer bindings exposed to the template scope
  • event logging so the host app can process button results later

The plugin owns shared persistence, declarative action execution, and event retrieval. The host widget extension keeps full freedom over actual WidgetKit rendering, including Home Screen / SpringBoard widgets backed by WidgetKit timelines.

Full-native widgets can use widget sessions for synchronous shared state and widget messages for asynchronous app/widget jobs without adopting the SVG template renderer.

areActivitiesSupported()

areActivitiesSupported() => Promise<ActivitiesSupportedResult>

Check whether the native template activity bridge can run on the current device.

Returns: Promise<ActivitiesSupportedResult>


startTemplateActivity(...)

startTemplateActivity(options: StartTemplateActivityOptions) => Promise<StartTemplateActivityResult>

Persist a generic SVG template activity and start the matching native Live Activity bridge.

ParamType
optionsStartTemplateActivityOptions

Returns: Promise<StartTemplateActivityResult>


startTemplateWidget(...)

startTemplateWidget(options: StartTemplateWidgetOptions) => Promise<StartTemplateActivityResult>

Persist a generic SVG template for Home Screen / SpringBoard widgets without starting a Live Activity.

ParamType
optionsStartTemplateWidgetOptions

Returns: Promise<StartTemplateActivityResult>


updateTemplateActivity(...)

updateTemplateActivity(options: UpdateTemplateActivityOptions) => Promise<TemplateActivityResult>

Replace part or all of the stored activity definition/state.

ParamType
optionsUpdateTemplateActivityOptions

Returns: Promise<TemplateActivityResult>


endTemplateActivity(...)

endTemplateActivity(options: EndTemplateActivityOptions) => Promise<void>

End a running activity while optionally persisting one last state snapshot.

ParamType
optionsEndTemplateActivityOptions

performTemplateAction(...)

performTemplateAction(options: PerformTemplateActionOptions) => Promise<PerformTemplateActionResult>

Execute one declarative action and record the resulting event.

ParamType
optionsPerformTemplateActionOptions

Returns: Promise<PerformTemplateActionResult>


getTemplateActivity(...)

getTemplateActivity(options: GetTemplateActivityOptions) => Promise<TemplateActivityResult>

Read one activity back from the shared store.

ParamType
optionsGetTemplateActivityOptions

Returns: Promise<TemplateActivityResult>


listTemplateActivities()

listTemplateActivities() => Promise<ListTemplateActivitiesResult>

List every activity currently known by the plugin.

Returns: Promise<ListTemplateActivitiesResult>


listTemplateEvents(...)

listTemplateEvents(options?: ListTemplateEventsOptions | undefined) => Promise<ListTemplateEventsResult>

List stored action events so the app can react to widget interactions later.

ParamType
optionsListTemplateEventsOptions

Returns: Promise<ListTemplateEventsResult>


acknowledgeTemplateEvents(...)

acknowledgeTemplateEvents(options: AcknowledgeTemplateEventsOptions) => Promise<void>

Mark previously processed events as acknowledged.

ParamType
optionsAcknowledgeTemplateEventsOptions

startWidgetSession(...)

startWidgetSession(options: StartWidgetSessionOptions) => Promise<StartWidgetSessionResult>

Start a full-native widget session backed by shared JSON state.

ParamType
optionsStartWidgetSessionOptions

Returns: Promise<StartWidgetSessionResult>


updateWidgetSession(...)

updateWidgetSession(options: UpdateWidgetSessionOptions) => Promise<WidgetSessionResult>

Update a full-native widget session.

ParamType
optionsUpdateWidgetSessionOptions

Returns: Promise<WidgetSessionResult>


stopWidgetSession(...)

stopWidgetSession(options: StopWidgetSessionOptions) => Promise<void>

Stop a full-native widget session.

ParamType
optionsStopWidgetSessionOptions

getWidgetSession(...)

getWidgetSession(options: GetWidgetSessionOptions) => Promise<WidgetSessionResult>

Read one full-native widget session.

ParamType
optionsGetWidgetSessionOptions

Returns: Promise<WidgetSessionResult>


listWidgetSessions()

listWidgetSessions() => Promise<ListWidgetSessionsResult>

List every full-native widget session currently known by the plugin.

Returns: Promise<ListWidgetSessionsResult>


sendWidgetMessage(...)

sendWidgetMessage(options: SendWidgetMessageOptions) => Promise<SendWidgetMessageResult>

Queue a message between the app and native widget code.

ParamType
optionsSendWidgetMessageOptions

Returns: Promise<SendWidgetMessageResult>


listWidgetMessages(...)

listWidgetMessages(options?: ListWidgetMessagesOptions | undefined) => Promise<ListWidgetMessagesResult>

List queued full-native widget bridge messages.

ParamType
optionsListWidgetMessagesOptions

Returns: Promise<ListWidgetMessagesResult>


acknowledgeWidgetMessages(...)

acknowledgeWidgetMessages(options: AcknowledgeWidgetMessagesOptions) => Promise<void>

Mark widget bridge messages as acknowledged after processing.

ParamType
optionsAcknowledgeWidgetMessagesOptions

completeWidgetMessage(...)

completeWidgetMessage(options: CompleteWidgetMessageOptions) => Promise<WidgetMessageResult>

Complete or fail an async widget bridge message.

ParamType
optionsCompleteWidgetMessageOptions

Returns: Promise<WidgetMessageResult>


reloadWidgets(...)

reloadWidgets(options?: ReloadWidgetsOptions | undefined) => Promise<void>

Ask native widgets to reload after external app state changes.

ParamType
optionsReloadWidgetsOptions

getPluginVersion()

getPluginVersion() => Promise<PluginVersionResult>

Return the platform implementation version marker.

Returns: Promise<PluginVersionResult>


Interfaces

ActivitiesSupportedResult

Result of a Live Activities capability check.

PropTypeDescription
supportedbooleanWhether the current device and runtime can run the native template activity bridge.
reasonstringHuman-readable reason when support is unavailable.

StartTemplateActivityResult

Result when starting a generic template activity.

PropTypeDescription
activitySvgTemplateActivityRecordStored activity snapshot.

SvgTemplateActivityRecord

Stored activity snapshot returned by the plugin.

PropTypeDescription
activityIdstringStable plugin activity identifier.
definitionSvgTemplateDefinitionFull template definition.
stateSvgTemplateStatePersisted JSON state.
timersRecord<string, SvgTemplateTimerState>Timer runtime state keyed by timer id.
status'active' | 'ended'Current lifecycle status.
openUrlstringOptional deep link opened when the widget body is tapped.
updatedAtnumberLast update timestamp.
revisionnumberMonotonic revision incremented on every state change.

SvgTemplateDefinition

Generic SVG template definition stored by the plugin.

PropTypeDescription
idstringStable template identifier.
versionstringOptional version marker for migrations.
layoutsSvgTemplateLayoutsAvailable WidgetKit layouts.
actionsSvgTemplateActionDefinition[]Optional declarative actions.
timersSvgTemplateTimerDefinition[]Optional timer definitions exposed to the template runtime.
metadataJsonObjectOptional JSON metadata mirrored in the runtime scope under meta.template.

SvgTemplateLayouts

Bundle of optional WidgetKit surface layouts.

PropTypeDescription
homeScreenSvgTemplateLayoutOptional Home Screen / SpringBoard widget layout. When omitted, native Home Screen widgets may fall back to lockScreen.
lockScreenSvgTemplateLayoutOptional lock-screen / Live Activity banner layout.
dynamicIslandExpandedSvgTemplateLayoutOptional expanded Dynamic Island layout.
dynamicIslandCompactLeadingSvgTemplateLayoutOptional compact leading Dynamic Island layout.
dynamicIslandCompactTrailingSvgTemplateLayoutOptional compact trailing Dynamic Island layout.
dynamicIslandMinimalSvgTemplateLayoutOptional minimal Dynamic Island layout.

SvgTemplateLayoutWithSvg

SVG layout variant backed by a base SVG string.

PropTypeDescription
svgstringRaw SVG template string used when no frame is selected. The runtime resolves {{state.*}}, {{timers.*}}, and {{meta.*}} placeholders before rendering.
framesSvgTemplateFrame[]Optional named SVG frames for click-driven or timer-driven frame changes.
frameIdPathstringOptional state/runtime path that resolves to the active frame id. Examples: state.frame, state.widgets.{{state.activeIndex}}.frame, or {{state.frame}}.
defaultFrameIdstringFrame id used when frameIdPath is missing or resolves to an unknown frame.
widthnumberNominal SVG width used for scaling hotspots.
heightnumberNominal SVG height used for scaling hotspots.
hotspotsSvgTemplateHotspot[]Interactive overlay regions.

SvgTemplateFrame

Named SVG frame that can be selected by activity state.

PropTypeDescription
idstringStable frame identifier.
svgstringRaw SVG template string for this frame. The runtime resolves {{state.*}}, {{timers.*}}, and {{meta.*}} placeholders before rendering.
hotspotsSvgTemplateHotspot[]Optional frame-specific interactive regions. When omitted, the parent layout hotspots are used.

SvgTemplateHotspot

Interactive region overlaid on top of a rendered SVG layout.

PropTypeDescription
idstringStable hotspot identifier.
actionIdstringAction identifier executed when the region is tapped.
xnumberX position in the SVG coordinate space.
ynumberY position in the SVG coordinate space.
widthnumberHotspot width in the SVG coordinate space.
heightnumberHotspot height in the SVG coordinate space.
labelstringOptional accessibility label for the interactive region.
role'button' | 'link'Optional semantic role.
payloadJsonObjectOptional static payload forwarded when the hotspot triggers its action.

JsonObject

JSON-safe object used as activity state.

SvgTemplateLayoutWithFrames

SVG layout variant backed by named SVG frames.

PropTypeDescription
svgstringRaw SVG template string used when no frame is selected. The runtime resolves {{state.*}}, {{timers.*}}, and {{meta.*}} placeholders before rendering.
framesSvgTemplateFrame[]Named SVG frames for click-driven or timer-driven frame changes.
frameIdPathstringOptional state/runtime path that resolves to the active frame id. Examples: state.frame, state.widgets.{{state.activeIndex}}.frame, or {{state.frame}}.
defaultFrameIdstringFrame id used when frameIdPath is missing or resolves to an unknown frame.
widthnumberNominal SVG width used for scaling hotspots.
heightnumberNominal SVG height used for scaling hotspots.
hotspotsSvgTemplateHotspot[]Interactive overlay regions.

SvgTemplateActionDefinition

Declarative action attached to one or more hotspots.

PropTypeDescription
idstringStable action identifier.
eventNamestringOptional event name used in the action log.
labelstringOptional UI label.
patchesSvgTemplateStatePatch[]Ordered state mutations executed when the action runs.
timerMutationsSvgTemplateTimerMutation[]Ordered timer mutations executed when the action runs.
frameMutationsSvgTemplateFrameMutation[]Ordered frame mutations executed when the action runs.
openUrlstringOptional deep link opened by the host widget when the action runs.

SvgTemplateStatePatch

Declarative mutation applied to the stored activity state.

PropTypeDescription
op'set' | 'increment' | 'toggle' | 'unset' | 'timestamp'Mutation operation.
pathstringDestination state path. The path may itself contain {{...}} placeholders.
valueJsonValueOptional literal value used by the mutation.
valuePathstringOptional source path used to copy a value from the current runtime scope. The path may itself contain {{...}} placeholders.
valueTemplatestringOptional template-resolved value. If the string is a single {{...}} token, the raw referenced JSON value is copied. Otherwise the resolved string is stored.
amountnumberIncrement amount for increment.

SvgTemplateTimerMutation

Declarative timer mutation triggered by an action.

PropTypeDescription
op'toggle' | 'start' | 'stop' | 'restart' | 'pause' | 'resume' | 'reset' | 'setDuration'Mutation operation.
timerIdstringTarget timer identifier.
durationMsnumberOptional fixed duration override in milliseconds.
durationPathstringOptional path that resolves to a duration override in milliseconds. The path may itself contain {{...}} placeholders.

SvgTemplateFrameMutation

Declarative frame mutation triggered by an action.

PropTypeDescription
op'set' | 'toggle' | 'next' | 'previous'Mutation operation.
pathstringDestination state path that stores the active frame id. The path may itself contain {{...}} placeholders.
frameIdstringFrame id used by set, or the alternate frame id used by toggle. The value may contain {{...}} placeholders.
frameIdsstring[]Ordered frame ids used by next, previous, and toggle. When omitted, surface can be used to read frame ids from a layout definition.
surfaceSvgTemplateSurfaceOptional surface whose layout frames should be used when frameIds is omitted.
wrapbooleanWhether next and previous wrap at the ends. Defaults to true.

SvgTemplateTimerDefinition

Timer binding exposed to SVG templates.

PropTypeDescription
idstringStable timer identifier.
durationMsnumberOptional fixed duration in milliseconds.
durationPathstringOptional state path that resolves to a duration in milliseconds. The path may itself contain {{...}} placeholders.
startAtPathstringOptional state path that resolves to the timer start timestamp in milliseconds. The path may itself contain {{...}} placeholders.
autoStartbooleanWhen true, the timer starts automatically when the activity is created.

SvgTemplateTimerState

Persisted timer runtime state.

PropTypeDescription
idstringTimer identifier.
startedAtnumber | nullStart timestamp in milliseconds, or null when the timer is idle.
elapsedMsnumberElapsed milliseconds already accumulated before the current run. This is used to preserve timer progress while paused.
durationMsnumberCurrent timer duration in milliseconds.
status'idle' | 'running' | 'paused' | 'finished' | 'stopped'Current timer status.
updatedAtnumberLast update timestamp.

StartTemplateActivityOptions

Options for starting a generic SVG template activity.

PropTypeDescription
activityIdstringOptional explicit activity identifier. When omitted, the native runtime creates one.
definitionSvgTemplateDefinitionGeneric SVG template definition.
stateSvgTemplateStateInitial JSON state exposed under state.*.
openUrlstringOptional deep link used when the widget body is tapped.
startLiveActivitybooleanWhether iOS should also start a native Live Activity. Defaults to true. Set to false when the same SVG template should only back a home-screen or lock-screen widget surface.

StartTemplateWidgetOptions

Options for starting or replacing a Home Screen / SpringBoard widget template.

This persists the same SVG template record as startTemplateActivity, but native iOS implementations do not start an ActivityKit Live Activity.

PropTypeDescription
activityIdstringOptional explicit activity identifier. When omitted, the native runtime creates one.
definitionSvgTemplateDefinitionGeneric SVG template definition.
stateSvgTemplateStateInitial JSON state exposed under state.*.
openUrlstringOptional deep link used when the widget body is tapped.

TemplateActivityResult

Result when reading or updating a single activity.

PropTypeDescription
activitySvgTemplateActivityRecord | nullStored activity snapshot, or null when not found.

UpdateTemplateActivityOptions

Options for updating an existing template activity.

PropTypeDescription
activityIdstringActivity identifier returned by startTemplateActivity.
definitionSvgTemplateDefinitionOptional replacement definition.
stateSvgTemplateStateOptional replacement state.
openUrlstringOptional replacement deep link.

EndTemplateActivityOptions

Options for ending a template activity.

PropTypeDescription
activityIdstringActivity identifier returned by startTemplateActivity.
stateSvgTemplateStateOptional final state persisted before ending.

PerformTemplateActionResult

Result after executing an action.

PropTypeDescription
activitySvgTemplateActivityRecordUpdated activity snapshot.
eventSvgTemplateActionEventAction event emitted by the runtime.

SvgTemplateActionEvent

Event emitted whenever a declarative action is executed.

PropTypeDescription
eventIdstringStable event identifier.
activityIdstringActivity identifier associated with the event.
actionIdstringAction identifier that produced the event.
eventNamestringOptional event name copied from the action definition.
sourceIdstringOptional source identifier, typically the hotspot id that triggered the action.
createdAtnumberEvent creation timestamp in milliseconds.
acknowledgedAtnumber | nullTimestamp in milliseconds when the app acknowledged the event.
payloadJsonObject | nullOptional caller-provided payload.
stateSvgTemplateStateState snapshot after the action was applied.
timersRecord<string, SvgTemplateTimerState>Timer snapshot after the action was applied.

PerformTemplateActionOptions

Options for executing a declarative action.

PropTypeDescription
activityIdstringActivity identifier returned by startTemplateActivity.
actionIdstringAction identifier declared in the template definition.
sourceIdstringOptional source identifier, typically the hotspot id that triggered the action.
payloadJsonObjectOptional payload stored with the emitted event and exposed to declarative patches under {{action.payload.*}}.

GetTemplateActivityOptions

Options for reading one stored activity.

PropTypeDescription
activityIdstringActivity identifier to load.

ListTemplateActivitiesResult

Result when listing stored activities.

PropTypeDescription
activitiesSvgTemplateActivityRecord[]Stored activity snapshots.

ListTemplateEventsResult

Result when listing action events.

PropTypeDescription
eventsSvgTemplateActionEvent[]Matching action events.

ListTemplateEventsOptions

Options when listing action events.

PropTypeDescription
activityIdstringOptional activity filter.
unacknowledgedOnlybooleanWhen true, only unacknowledged events are returned.

AcknowledgeTemplateEventsOptions

Options for acknowledging events after the host app processes them.

PropTypeDescription
eventIdsstring[]Optional explicit event ids to acknowledge.
activityIdstringOptional activity id shortcut that acknowledges every event for the activity.

StartWidgetSessionResult

Result when starting a full-native widget session.

PropTypeDescription
sessionWidgetSessionRecordStored session snapshot.

WidgetSessionRecord

Stored full-native widget session.

PropTypeDescription
widgetIdstringStable widget/session identifier.
kindstringOptional product-defined session kind.
stateJsonObjectJSON state shared synchronously between the app and native widget code.
metadataJsonObjectOptional JSON metadata for native widget code.
status'active' | 'stopped'Current session status.
createdAtnumberCreation timestamp.
updatedAtnumberLast update timestamp.
revisionnumberMonotonic revision incremented on every session state change.

StartWidgetSessionOptions

Options for starting a full-native widget session.

PropTypeDescription
widgetIdstringOptional explicit widget/session identifier. When omitted, the native runtime creates one.
kindstringOptional product-defined session kind.
stateJsonObjectInitial shared state.
metadataJsonObjectOptional metadata for native widget code.

WidgetSessionResult

Result when reading or updating one full-native widget session.

PropTypeDescription
sessionWidgetSessionRecord | nullStored session snapshot, or null when not found.

UpdateWidgetSessionOptions

Options for updating a full-native widget session.

PropTypeDescription
widgetIdstringWidget/session identifier returned by startWidgetSession.
stateJsonObjectReplacement or merge patch for shared state.
metadataJsonObjectReplacement or merge patch for metadata.
mergebooleanWhen true, object values are deep-merged instead of replaced.

StopWidgetSessionOptions

Options for stopping a full-native widget session.

PropTypeDescription
widgetIdstringWidget/session identifier returned by startWidgetSession.
stateJsonObjectOptional final shared state.

GetWidgetSessionOptions

Options for reading one full-native widget session.

PropTypeDescription
widgetIdstringWidget/session identifier to load.

ListWidgetSessionsResult

Result when listing full-native widget sessions.

PropTypeDescription
sessionsWidgetSessionRecord[]Stored session snapshots.

SendWidgetMessageResult

Result after sending a widget bridge message.

PropTypeDescription
messageWidgetBridgeMessageStored message snapshot.

WidgetBridgeMessage

Queued message used for async app/widget jobs.

PropTypeDescription
messageIdstringStable message identifier.
widgetIdstringWidget/session identifier associated with the message.
directionWidgetMessageDirectionMessage direction.
namestringProduct-defined message or job name.
payloadJsonObject | nullOptional JSON payload.
expectsResponsebooleanWhether the sender expects a later response.
statusWidgetMessageStatusCurrent message status.
createdAtnumberMessage creation timestamp.
acknowledgedAtnumber | nullTimestamp in milliseconds when the receiver acknowledged the message.
completedAtnumber | nullTimestamp in milliseconds when the message was completed or failed.
responseJsonObject | nullOptional JSON response for async jobs.
errorstring | nullOptional failure message for async jobs.

SendWidgetMessageOptions

Options for sending a full-native widget bridge message.

PropTypeDescription
widgetIdstringWidget/session identifier associated with the message.
namestringProduct-defined message or job name.
directionWidgetMessageDirectionOptional message direction. Defaults to appToWidget when called from the app.
payloadJsonObjectOptional JSON payload.
expectsResponsebooleanWhether the sender expects a later response.

ListWidgetMessagesResult

Result when listing full-native widget bridge messages.

PropTypeDescription
messagesWidgetBridgeMessage[]Matching messages.

ListWidgetMessagesOptions

Options when listing full-native widget bridge messages.

PropTypeDescription
widgetIdstringOptional widget/session filter.
directionWidgetMessageDirectionOptional direction filter.
unacknowledgedOnlybooleanWhen true, only unacknowledged messages are returned.
pendingOnlybooleanWhen true, only pending messages are returned.

AcknowledgeWidgetMessagesOptions

Options for acknowledging widget bridge messages after processing them.

PropTypeDescription
messageIdsstring[]Optional explicit message ids to acknowledge.
widgetIdstringOptional widget/session shortcut that acknowledges matching messages.
directionWidgetMessageDirectionOptional direction filter.

WidgetMessageResult

Result after completing a widget bridge message.

PropTypeDescription
messageWidgetBridgeMessage | nullStored message snapshot, or null when not found.

CompleteWidgetMessageOptions

Options for completing an async widget bridge message.

PropTypeDescription
messageIdstringMessage identifier returned by sendWidgetMessage.
responseJsonObjectOptional JSON response payload.
errorstringOptional error string. When set, the message status becomes failed.

ReloadWidgetsOptions

Options for forcing installed native widgets to reload their timeline.

PropTypeDescription
kindstringOptional native widget kind to reload on iOS. When omitted, every widget timeline is reloaded.

PluginVersionResult

Result payload for plugin version queries.

PropTypeDescription
versionstringNative implementation version marker.

Type Aliases

SvgTemplateLayout

SVG layout variant for one WidgetKit surface.

SvgTemplateLayoutWithSvg | SvgTemplateLayoutWithFrames

JsonValue

Any JSON-safe value accepted by the plugin.

JsonPrimitive | JsonObject | JsonArray

JsonPrimitive

JSON-safe primitive value.

string | number | boolean | null

JsonArray

JSON-safe array used as activity state.

JsonValue[]

SvgTemplateSurface

Named WidgetKit surface for one SVG layout variant.

'homeScreen' | 'lockScreen' | 'dynamicIslandExpanded' | 'dynamicIslandCompactLeading' | 'dynamicIslandCompactTrailing' | 'dynamicIslandMinimal'

SvgTemplateState

Structured state payload persisted for an activity.

JsonObject

Record

Construct a type with a set of properties K of type T

{ [P in K]: T; }

WidgetMessageDirection

Message direction for the full-native widget bridge.

'appToWidget' | 'widgetToApp'

WidgetMessageStatus

Completion status for a full-native widget bridge message.

'pending' | 'completed' | 'failed'