{"id":19952294,"url":"https://github.com/sparrowcode/live-activity-example","last_synced_at":"2025-10-07T08:33:41.857Z","repository":{"id":103223356,"uuid":"555294956","full_name":"sparrowcode/live-activity-example","owner":"sparrowcode","description":"Example how to make, update and end Live Activity. With Dynamic Island and Lock Screen.","archived":false,"fork":false,"pushed_at":"2024-04-11T15:41:13.000Z","size":121,"stargazers_count":30,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-07T20:21:24.349Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sparrowcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-21T09:52:30.000Z","updated_at":"2025-02-18T19:50:49.000Z","dependencies_parsed_at":"2024-11-18T06:35:51.281Z","dependency_job_id":null,"html_url":"https://github.com/sparrowcode/live-activity-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparrowcode%2Flive-activity-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparrowcode%2Flive-activity-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparrowcode%2Flive-activity-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparrowcode%2Flive-activity-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sparrowcode","download_url":"https://codeload.github.com/sparrowcode/live-activity-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252241925,"owners_count":21717069,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T01:12:31.818Z","updated_at":"2025-10-07T08:33:36.808Z","avatar_url":"https://github.com/sparrowcode.png","language":"Swift","readme":"![](https://cdn.sparrowcode.io/tutorials/live-activities/live-activity-type-compact.png)\n\n# Live Activity Example\n\nExample how to make, update and end Live Activity. With Dynamic Island and Lock Screen.\u003cbr\u003e\n**Full tutorial available at [sparrowcode.io](https://sparrowcode.io/tutorials/live-activities)**.\n\nLive Activity already enabled for upload with Xcode 14.1 RC.\n\n\u003e **Note**\n\u003e Supported only for iOS \u003e=16.1\n\n## Preparing Project\n\nAdd Widget target:\n\n\u003cimg src=\"https://cdn.sparrowcode.io/tutorials/live-activities/add-widget-target.png\" width=\"500\"\u003e\n\nOr skip it if already supporting widgets. Next add to `Info.plist` key `Supports Live Activities` to true:\n\n```\n\u003ckey\u003eNSSupportsLiveActivities\u003c/key\u003e\n\u003ctrue/\u003e\n```\n\n## Define Model\n\nDefine model-data. There is dynamic and static properties. Dynamic can be updated in time and make changes in UI. Static using only for launch Live Activity.\n\n```swift\nstruct ActivityAttribute: ActivityAttributes {\n    \n    public struct ContentState: Codable, Hashable {\n        \n        // Dynamic properties.\n        // Can be updated when Live Actvity created.\n        \n        var dynamicStringValue: String\n        var dynamicIntValue: Int\n        var dynamicBoolValue: Bool\n        \n    }\n    \n    // Static properties.\n    // Used only when make live actvity.\n    // Can't update it later.\n    \n    var staticStringValue: String\n    var staticIntValue: Int\n    var staticBoolValue: Bool\n}\n```\n\n## Add UI\n\nDefine `Widget` wrapper:\n\n```swift\nstruct LiveActivityWidget: Widget {\n    \n    let kind: String = \"LiveActivityWidget\"\n    \n    var body: some WidgetConfiguration {\n        ActivityConfiguration(for: ActivityAttribute.self) { context in\n            // UI for lock screen\n        } dynamicIsland: { context in\n            // UI for Dynamic Island\n        }\n    }\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparrowcode%2Flive-activity-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsparrowcode%2Flive-activity-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparrowcode%2Flive-activity-example/lists"}