KasyKasy

Home Screen Widget

Add a widget to the iOS and Android home screen. All the native plumbing already ships ready.

A home screen widget (the one users place next to their icons) on both systems. All the native part already ships in the project: the Xcode target, Kotlin Glance, entitlements, App Group.

Implementation

Via MCP: ask your assistant "add widget to my project". It runs add_feature for you. See Kasy MCP.

  1. Run:

    kasy add widget
  2. Customize the displayed data by editing the update() method in lib/core/home_widgets/home_widget_mywidget_service.dart:

    1. In update(), save the fields via HomeWidget.saveWidgetData('key', 'value')
    2. On iOS: read them with UserDefaults(suiteName: appGroupId) and render with SwiftUI
    3. On Android: read them with currentState.preferences.getString('key', 'default') and render with Glance Compose
  3. On iOS, confirm the App Group (group.<your-bundle-id>) exists on your Apple account. Xcode with automatic signing creates it on its own on the first build. If it fails:

    1. developer.apple.com → Identifiers
    2. Register group.<your-bundle-id> (e.g., group.com.example.myapp)
    3. Enable it on both App IDs: the main app and <bundle-id>.HomeWidgetExtension
    4. Regenerate the profiles in Xcode
    App Group enabled on the extension's App ID at developer.apple.com
    developer.apple.com: App Groups capability enabled on the HomeWidgetExtension App ID

    On Android there's no extra configuration needed: it works on the emulator and physical devices out of the box.

Information

What already comes ready

PartiOSAndroid
Dependencies (home_widget, background_fetch)YesYes
Dart code (initialization, background task)YesYes
Swift Widget Extension + Xcode targetYesNo
Entitlements with App GroupYesNo
MyWidget.kt (Glance) + receiverNoYes
Registration in AndroidManifest.xmlNoYes
Bundle ID replaced automaticallyYesYes

Default content

The delivered widget shows two fields as an example:

  • title: e.g. "Hi, {userId}"
  • counter: a number or short text, defaults to "0"

Customizing

LayerFileIDE
Data (what to send)home_widget_mywidget_service.dartupdate()VS Code
iOS visualsios/HomeWidgetExtension/MyWidget.swiftXcode
Android visualsandroid/.../MyWidget.ktAndroid Studio

How the widget updates

background_fetch runs roughly every ~15 minutes even with the app closed. It calls MyWidgetHomeWidget.update(), which saves the data and tells the system to redraw.

To force a manual update during development: Admin Console → Tools → Update MyWidget.

On the iOS simulator you can test layout and data. Background updates and taps are inconsistent in the simulator: use a physical device for real behavior.

Last updated on 08/02/2026