I've implemented the live activities, and getting no issues so far. It's getting created, but is not visible in notification center, and no error is being thrown
I'm using XCode 15.0 beta 8 and testing on real device iOS 17.0
Below is my NotificationLiveActivity.swift file
import ActivityKit
import WidgetKit
import SwiftUI
struct NotificationAttributes: ActivityAttributes {
public struct ContentState: Codable, Hashable {
var title: String
var label: String
}
var id: String
}
@available(iOS 16.2, *)
struct NotificationLiveActivity: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: NotificationAttributes.self) { context in
Text(context.state.title)
} dynamicIsland: { context in
DynamicIsland {
// Expanded UI goes here. Compose the expanded UI through
// various regions, like leading/trailing/center/bottom
DynamicIslandExpandedRegion(.leading) {
Text(context.state.title)
}
DynamicIslandExpandedRegion(.trailing) {
Text(context.state.label)
}
DynamicIslandExpandedRegion(.bottom) {
Text(context.state.title)
}
} compactLeading: {
Text(context.state.title)
} compactTrailing: {
Text(context.state.label)
} minimal: {
Text(context.state.title)
}
.widgetURL(URL(string: "http://www.apple.com"))
.keylineTint(Color.red)
}
}
}
Here's the snippet where activity is created:
func startLiveActivity(title: String, label: String) {
let attributes = NotificationAttributes(id: "")
let state = NotificationAttributes.ContentState(
title: title, label: label
)
do {
stopwatchActivity = try Activity<NotificationAttributes>.request(
attributes: attributes, contentState: state, pushType: nil)
NSLog("activity id: \(stopwatchActivity?.id ?? "")")
NSLog("description: \(stopwatchActivity?.content.description ?? "")")
} catch(let e) {
NSLog("error: \(e)")
}
}
Logs screenshot:

It's expected to show live activity in notification center
Unchecking Copy only when installing fixed the issue

Update 1:
If the above solution doesn't work, restart your iPhone
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With