Example how to make, update and end Live Activity. With Dynamic Island and Lock Screen.

Overview

Live Activity Example

Example how to make, update and end Live Activity. With Dynamic Island and Lock Screen.
Full tutorial available at sparrowcode.io.

Live Activity already enabled for upload with Xcode 14.1 RC.

Note Supported only for iOS >=16.1

Preparing Project

Add Widget target:

Or skip it if already supporting widgets. Next add to Info.plist key Supports Live Activities to true:

<key>NSSupportsLiveActivities</key>
<true/>

Define Model

Define 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.

struct ActivityAttribute: ActivityAttributes {
    
    public struct ContentState: Codable, Hashable {
        
        // Dynamic properties.
        // Can be updated when Live Actvity created.
        
        var dynamicStringValue: String
        var dynamicIntValue: Int
        var dynamicBoolValue: Bool
        
    }
    
    // Static properties.
    // Used only when make live actvity.
    // Can't update it later.
    
    var staticStringValue: String
    var staticIntValue: Int
    var staticBoolValue: Bool
}

Add UI

Define Widget wrapper:

struct LiveActivityWidget: Widget {
    
    let kind: String = "LiveActivityWidget"
    
    var body: some WidgetConfiguration {
        ActivityConfiguration(for: ActivityAttribute.self) { context in
            // UI for lock screen
        } dynamicIsland: { context in
            // UI for Dynamic Island
        }
    }
}
You might also like...
OnBoardSwiftUI-Food - Food App Onboarding screen made with SwiftUI
OnBoardSwiftUI-Food - Food App Onboarding screen made with SwiftUI

OnBoardSwiftUI-Food Food App Onboarding screen made with SwiftUI. App Details Lo

SharedImages Screen grabs Main Features Private & self-owned social media Users store their images in their own cloud storage (Dropbox or Google Drive

SharedImages Screen grabs Main Features Private & self-owned social media Users store their images in their own cloud storage (Dropbox or Google Drive

A Collection of PropertyWrappers to make custom Serialization of Swift Codable Types easy

CodableWrappers Simplified Serialization with Property Wrappers Move your Codable and (En/De)coder customization to annotations! struct YourType: Coda

Snapify is an opensource tweak to make the messages app behave like Snapchat's sending system

Snapify A simple tweak to remove the send button in messages, replaced by keyboard key What is Snapify? Snapify is an opensource tweak to make the mes

Dicee-SwiftUI - This app show random dicee every time the you make click in button roll
Dicee-SwiftUI - This app show random dicee every time the you make click in button roll

Dicee-SwiftUI This app show random dicee every time the you make click in button

SyntaxTree - This code attempts to make basic syntax trees in the Xcode console

SyntaxTree This code attempts to make basic syntax trees in the Xcode console. I

Modular iOS with Uber needle & tuist example
Modular iOS with Uber needle & tuist example

Dodi Modular iOS with Uber needle & tuist example Setup brew install needle bash (curl -Ls https://install.tuist.io) and run make all Point of concer

Distributed actors transport example, for feature review

swift-sample-distributed-actors-transport Sample application and ActorTransport, associated with distributed actor language evolution proposal. Runnin

Example project for the DeDuplicatingEntity Protocol

DeDuplicatingEntity-Sample-Project Example project for the DeDuplicatingEntity Swift Package Clone this repo and build the sample project or use it in

Owner
Sparrow Code
Helping iOS developers
Sparrow Code
Refresh your Live Activity with the "sound" background mode.

Live Activity Background Update Demo A demo about how to refresh Live Activity with the "sound" background mode. The Basics While in the background, L

Megabits_mzq 6 Nov 4, 2022
๐Ÿ“ Read, update and write your Xcode projects

XcodeProj XcodeProj is a library written in Swift for parsing and working with Xcode projects. It's heavily inspired by CocoaPods XcodeProj and xcode.

Tuist 1.7k Nov 20, 2022
Activity Content SDK

Activity-content-swift - The Activity Content SDK is a library that supports converting DSNP Activity Content data to and from JSON

ProjectLiberty.io 0 Jan 26, 2022
An iOS App which shows live AQI (Air quality index) data for different cities using Web-socket

AQI - Assignment This is an iOS App which shows live AQI (Air quality index) dat

Pratik Prajapati 3 Jul 21, 2022
Static Native Template and Dynamic Styling without any other app release

FileManager Project Students and Freshers, Good opportunity for you to learn and contribute in this project. Here you would learn how you can change t

Naveen Chauhan 3 Nov 30, 2021
Create dynamic wallpapers for macOS

Equinox Create macOS native wallpapers Description Equinox is an application that allows you to create macOS native wallpapers. Starting macOS Mojave

Dmitry Meduho 637 Nov 12, 2022
A Kotlin multiplatform library for building dynamic server-driven UI

Component Box ยท A Kotlin multiplatform library for building dynamic server-driven UI. Material Component-Based Interoperable Dynamic What You See Is W

Dropbox 210 Nov 17, 2022
A dynamic sitemap generator for Vapor

A dynamic sitemap generator for Vapor

Vapor Community 5 Apr 21, 2022
Custom MacBook login screen and pam modules using multipeer connectivity and usb hardware checks with iOS app for sign in.

Custom MacBook login screen and pam modules using multipeer connectivity and usb hardware checks with iOS app for sign in.

null 2 Aug 17, 2022
How to develop an iOS 14 application with SwiftUI 2.0 framework. How to create an Onboarding Screen with Page Tab View

Ama-Fruits USER INTERFACE AND USER EXPERIENCE APP DESIGN How to develop an iOS 14 application with SwiftUI 2.0 framework. How to create an Onboarding

Noye Samuel 1 Dec 11, 2021