I want to add my app to Controls, just a button to open the app. The end goal is to put it on a lock screen. However, I can get it to work on the iPhone simulator, but I am unable to get it on my actual device. No warnings or failed build or signing issues. I feel like I have changed and tinkered everything. I feel like my code is correct, so maybe it's an issue of the signing? I am lost. Running the control center stuff through Widgetkit.
Widgets & Live Activities
RSS for tagDiscuss how to manage and implement Widgets & Live Activities.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Created
Q1. Can you place a sound on an end event? That doesn't seem to work for us
Additionally:
Q2. Is there any way that after you send the end event, still have the Live Activity remain on the Dynamic Island until the dismissal-date?
Currently when an end event is sent, it's abruptly ended from the Dynamic Island without any sound. Users are confused until minutes/hours later they see their Lock Screen.
Good morning,
We are implementing Live Activities in a push-to-start flow. We wrap the listener for push to start tokens in a high priority task:
if ptsListenerTask == nil || ptsListenerTask?.isCancelled == true {
ptsListenerTask = Task(priority: .high) { [weak self] in
for await pushToken in Activity<LiveAuctionAttributes>.pushToStartTokenUpdates {
//Send token to back-end
}
}
I've tried a few variations of this and they work well on most devices. I have seen a couple of devices that refuse to issue a push to start token.
The user will have logging for the init flow and starting the PTS listener then the logs just go silent, nothing happens.
One thing that seemed to work was getting the user to start a Live Activity manually (from our debugging tool) then the PTS token gets issued.
This is not very reliable and working a mock live activity into the flow for obtaining a PTS token is a poor solution.
Is anyone else seeing this and is there a known issue with obtaining PTS tokens?
Thanks!
Brad
import AppIntents
struct AddTodoIntent: AppIntent {
static var title: LocalizedStringResource = "Add Todo"
static var openAppWhenRun: Bool = true
func perform() async throws -> some IntentResult & ProvidesDialog {
.result(dialog: "New todo added successfully.")
}
}
struct ViewTodosIntent:AppIntent {
static var title: LocalizedStringResource = "View Todos"
func perform() async throws -> some IntentResult & ProvidesDialog {
.result(dialog: "Here are your todos...")
}
}
struct TodoAppShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: AddTodoIntent(),
phrases: ["\(.applicationName) Add a new todo"],
shortTitle: "New Todo",
systemImageName: "plus.circle"
)
AppShortcut(
intent: ViewTodosIntent(),
phrases: ["\(.applicationName) Show my todoso"],
shortTitle: "Show todos",
systemImageName: "plus.app"
)
}
}
when we used, it wrong
How did i can do it success?
I have developed a Widget Extension with editable dynamic options.
`struct ModelQuery: EntityStringQuery {
public var allModels:[ModelEntity] {
// from App Groups UserDefaults
let models = SharedDataManager.getModelList()
// 检查原始数据是否为空,避免转换后的数据异常
guard !models.isEmpty else {
return []
}
let entites = models.map{ModelEntity(from: $0)}
return entites
}
func entities(for identifiers: [ModelEntity.ID]) async throws -> [ModelEntity] {
let models = allModels
if models.isEmpty {
return []
}
// 尝试匹配ID
let matchedEntities = identifiers.compactMap { id in
models.first { $0.id == id }
}
// 如果没有匹配到任何实体,返回默认的第一个站点
if matchedEntities.isEmpty && !models.isEmpty {
return [models[0]]
}
return matchedEntities
}
func entities(matching string: String) async throws -> [ModelEntity] {
let stations = allModels
if stations.isEmpty {
return []
}
if string.isEmpty {
return stations
}
let lowercasedString = string.lowercased()
let filteredStations = stations.filter { station in
station.name.lowercased().contains(lowercasedString)
}
if filteredStations.isEmpty {
return []
}
return filteredStations
}
func suggestedEntities() async throws -> [ModelEntity] {
return allModels
}
}`
Below is how it looks when functioning properly
However, when I tested it on iOS 26, occasional "Failed to Load" errors or unknown errors occurred. The same issues did not appear on iOS 17 or iOS 18.
When I set Alarm with fixed schedule(Alarm.Schedule.fixed(date))
LiveActivityIntent just work inconsistently
it sometimes call perfrom but cannot call other's
such as NotificationCenter.default.post
it just work fine with relativeSchedule but not for fixed schedule
i want to know why it happen
tested code is under below
struct StopIntent: LiveActivityIntent {
static var supportedModes: IntentModes = [.foreground(.immediate)]
func perform() throws -> some IntentResult {
guard let id = UUID(uuidString: alarmID) else {
NotificationCenter.default.post(name: .Alarm.stoped, object: alarmDataString)
throw TestAlarmManager._Error.badAlarmID
}
Task { @MainActor in
try TestAlarmManager.shared.stopAlarm(id)
NotificationCenter.default.post(name: .Alarm.stoped, object: alarmDataString)
}
return .result()
}
static var title: LocalizedStringResource = "Stop"
static var description = IntentDescription("Stop an alert")
@Parameter(title: "alarmID")
var alarmID: String
@Parameter(title: "alarmDataString")
var alarmDataString: String
init(alarmID: UUID, alarmDataString: String) {
self.alarmID = alarmID.uuidString
self.alarmDataString = alarmDataString
}
init() {
self.alarmID = ""
self.alarmDataString = ""
}
}
My widget has a background color set, but after the system sets custom transparency, my widget displays a blank space. I would like to solve this problem by obtaining the system's custom transparency settings and then setting the background color transparency, or do you have a better way to solve this problem
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
We currently have the need to develop Smart Island. We need to identify whether the current mobile phone supports Smart Island. At present, the solution we can think of is to maintain a model list if the current phone is in the white list, it supports Smart Island. But we think this method is not good enough. Is there a better solution to support identification? In addition, will the later models support smart Island?
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Create a static widget kit based widget for watchKit. Use swiftUI and an image.
IE on 42mm you can import a 141x141 image at 2x. Import a 141x141 image in the widget and load it in swiftUI.
In watchOS 11.x simulator the image will allow up to the size for X Large circles, and on os26, it will not load and complain the image is too large and report the area for the smaller circle, IE 89x89 @ 2x for 41mm
Also submitted a "feedback" ticket FB20506200
This is a big issue b/c the size difference for X large circles v the smaller circles is really large.
To get existing images to load I am having to resize them down 75-80% on OS26 in the X Large complication.
Hi,
We need Wallet Boarding Pass Live Activity style countdown inside Live Activity.
Requirements
Show only hours+minutes (no seconds ever).
Format examples (Turkish locale concept):
T > 60 min: "1sa 14d" (HHh MMm)
T < 60 min: "58d"
At exactly zero show a single final zero value (e.g. "0d").
Do NOT show seconds or any upward (elapsed) counting after zero.
When remaining time < 0 immediately replace display with status text (e.g. "ON TIME").
Never display negative or increasing elapsed time.
Discovered Current Timer Methods (Observed)
Method 1 (Text(date, style: .relative)):
After reaching target it continues counting UP (should stop).
Seconds appear automatically once remaining < 1 hour.
Method 2 (Text(date, style: .timer)):
After reaching target it continues counting UP (should stop).
Seconds are always visible from start.
Method 3 (Text(timerInterval: Date.now ... targetDate, countsDown: true)):
Stops at target (no upward counting) but seconds are always visible; cannot limit to single zero then freeze before status swap.
Requested Enhancement
Provide a behavior where the countdown displays hours+minutes, renders a single zero-minute value at the boundary (no seconds), then transitions to supplied status text.
Request
Public API or configuration to:
Select displayed units (hours, minutes only).
Stop automatic updating after rendering the zero frame (prevent upward counting).
Prevent post-target elapsed counting (no positive re-growth).
Allow immediate swap-to-text after zero (remaining < 0) while permitting a single zero display at the boundary.
Why
Align UX with Wallet; need predictable single zero then status, no seconds, no elapsed confusion.
Thank you.
Watching WWDC video: https://developer.apple.com/videos/play/wwdc2023/10185/?time=481
It says:
So when encoding your content state, do not set any custom encoding strategies. Otherwise, your JSON will be mismatched, and the system will fail to update your Live Activity
So I'm just wondering if using JSONDecoder is allowed for decoding apps payloads for the UI of a Live Activity? Or is there a performance hit for this?
I'm currently testing this on a physical device (12 Pro Max, iOS 26). Through shortcuts, I know for a fact that I am able to successfully trigger the perform code to do what's needed. In addition, if I just tell siri the phrase without my unit parameter, and it asks me which unit, I am able to, once again, successfully call my perform. The problem is any of my phrases that I include my unit, it either just opens my application, or says "I can't understand"
Here is my sample code:
My Entity:
import Foundation
import AppIntents
struct Unit: Codable, Identifiable {
let nickname: String
let ipAddress: String
let id: String
}
struct UnitEntity: AppEntity {
static var typeDisplayRepresentation: TypeDisplayRepresentation {
TypeDisplayRepresentation(
name: LocalizedStringResource("Unit", table: "AppIntents")
)
}
static let defaultQuery = UnitEntityQuery()
// Unique Identifer
var id: Unit.ID
// @Property allows this data to be available to Shortcuts, Siri, Etc.
@Property var name: String
// By not including @Property, this data is NOT used for queries.
var ipAddress: String
var displayRepresentation: DisplayRepresentation {
DisplayRepresentation(
title: "\(name)"
)
}
init(Unit: Unit) {
self.id = Unit.id
self.ipAddress = Unit.ipAddress
self.name = Unit.nickname
}
}
My Query:
struct UnitEntityQuery: EntityQuery {
func entities(for identifiers: [UnitEntity.ID]) async throws -> [UnitEntity] {
print("[UnitEntityQuery] Query for IDs \(identifiers)")
return UnitManager.shared.getUnitUnits()
.map { UnitEntity(Unit: $0) }
}
func suggestedEntities() async throws -> [UnitEntity] {
print("[UnitEntityQuery] Request for suggested entities.")
return UnitManager.shared.getUnitUnits()
.map { UnitEntity(Unit: $0) }
}
}
UnitsManager:
class UnitManager {
static let shared = UnitManager()
private init() {}
var allUnits: [UnitEntity] {
getUnitUnits().map { UnitEntity(Unit: $0) }
}
func getUnitUnits() -> [Unit] {
guard let jsonString = UserDefaults.standard.string(forKey: "UnitUnits"),
let data = jsonString.data(using: .utf8) else {
return []
}
do {
return try JSONDecoder().decode([Unit].self, from: data)
} catch {
print("Error decoding units: \(error)")
return []
}
}
func contactUnit(unit: UnitEntity) async -> Bool {
// Do things here...
}
}
My AppIntent:
import AppIntents
struct TurnOnUnit: AppIntent {
static let title: LocalizedStringResource = "Turn on Unit"
static let description = IntentDescription("Turn on an Unit")
static var parameterSummary: some ParameterSummary {
Summary("Turn on \(\.$UnitUnit)")
}
@Parameter(title: "Unit Unit", description: "The Unit Unit to turn on")
var UnitUnit: UnitEntity
func perform() async throws -> some IntentResult & ProvidesDialog {
//... My code here
}
}
And my ShortcutProvider:
import Foundation
import AppIntents
struct UnitShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: TurnOnUnit(),
phrases: [
"Start an Unit with \(.applicationName)",
"Using \(.applicationName), turn on my \(\.$UnitUnit)",
"Turn on my \(\.$UnitUnit) with \(.applicationName)",
"Start my \(\.$UnitUnit) with \(.applicationName)",
"Start \(\.$UnitUnit) with \(.applicationName)",
"Start \(\.$UnitUnit) in \(.applicationName)",
"Start \(\.$UnitUnit) using \(.applicationName)",
"Trigger \(\.$UnitUnit) using \(.applicationName)",
"Activate \(\.$UnitUnit) using \(.applicationName)",
"Volcano \(\.$UnitUnit) using \(.applicationName)",
],
shortTitle: "Turn on unit",
systemImageName: "bolt.fill"
)
}
}
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Tags:
Siri and Voice
Intents
App Intents
Appears during code compilation Provisioning profile "iOS Team Provisioning Profile: ..*" doesn't include the com.apple.developer.ActivityKit entitlement, Has anyone encountered or resolved a similar issue where the ActiveKit feature was not found in the developer's identifier, despite not being activated in the developer's system?
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Appears during code compilation Provisioning profile "iOS Team Provisioning Profile: ..*" doesn't include the com.apple.developer.ActivityKit entitlement, Has anyone encountered or resolved a similar issue where the ActiveKit feature was not found in the developer's identifier, despite not being activated in the developer's system?
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Appears during code compilation Provisioning profile "iOS Team Provisioning Profile: ..*" doesn't include the com.apple.developer.ActivityKit entitlement, Has anyone encountered or resolved a similar issue where the ActiveKit feature was not found in the developer's identifier, despite not being activated in the developer's system?
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Documentation seems to say that privacySensitive is supposed to redact on the lockScreen. I've disabled "Allow Access when locked" for "Lock Screen Widgets" just in case. It does not work for me. If I add "redacted(reason:) into the view hierarchy it redacts all the content all the time including on the home screen. I've read articles. I gone through a lot of documentation. None of them seem to give the magic formula for redacting sensitive content on the lock screen.
I'm using iOS 18.7 on a real iPhone 14 Pro Max.
Often times myself and others have left flashlight on by accident. Burning it out for sometime of being in pocket or left on table the light stays on the whole time because of just not realizing it was on. The front of phone shows flashlight icon is white when light is on, but this is not good enough! The icon needs to be a bright red or some other color so user can see that the light is actually still on. This would help alot , ty
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Attachments:
Problem Description:
I encountered an issue related to WidgetKit.
Inside a widget, I used the following API:
UIImage(named: "some_pic_in_asset")!
However, in my crash monitoring system, I observed a large number of crashes caused by force-unwrapping a UIImage that could not be loaded.
After analyzing the crash reports and the associated app version information, I found that this issue consistently occurs during the app upgrade process.
For example:
A user installs the app at version A and adds the widget to their Home Screen.
Later, the app is upgraded to version A+1.
Then, in the monitoring backend, I observe many crashes. The crash itself happens under version A, but the report is uploaded under version A+1.
Since crash collection happens in the widget and the report is uploaded by the app, the version mismatch is understandable. I also confirmed that the number of crashes strongly correlates with the number of app version upgrades.
Based on this analysis, I believe that in the upgrade scenario described above, UIImage(named: "some_pic_in_asset") sometimes fails to load the image even though it exists in the asset catalog. Please note that the force-unwrapping operation is not the focus of my concern here.
Question:
Is this a known system issue?
If so, is there a plan for fixing it in future iOS updates?
I'm having problems with my released app with iOS & WatchOS 26 support.
I've added AppIntentConfiguration support in the WatchOS app such that users can configure the complication. My complications also support multiple families and so I have slightly different configuration options available if its in the .accessoryRectangular slot or the .accessoryCircular one.
This works fine on Apple Watch when editing the Watch face. Here you can then select the configuration options fine and they are correct for the different variants.
However on iOS when configuring in the Apple Watch app on iPhone, the different complication size is ignored and the same configuration options are offered meaning they are wrong for one of them.
I created a sample project, here is the app intent code:
struct TestWidgetConfigurationIntent: AppIntent, WidgetConfigurationIntent {
static var title: LocalizedStringResource = "New Widgets with Configuration"
static var description = IntentDescription("Lots of stuff.")
static var isDiscoverable: Bool { return false}
init() {}
func perform() async throws -> some IntentResult {
return .result()
}
@Parameter(title: "Enable More Detail", default: true)
var moreDetail: Bool
@Parameter(title: "Enable Other Parameter", default: true)
var otherParameter: Bool
static var parameterSummary: some ParameterSummary {
When(widgetFamily: .equalTo, .accessoryRectangular) {
Summary("Test Info") {
\.$moreDetail
\.$otherParameter
}
} otherwise : {
Summary("Test Info") {
\.$moreDetail
}
}
}
}
In WatchOS you get the correct configuration options:
In iOS you do not, you get the same configuration option regardless of which family size you select:
This could be a bug so I've filed feedback FB20328319. Otherwise if anyone has insights, it would be very appreciated. This is all tested on the current iOS 26.0 and WatchOS 26.0 versions. Thanks!
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Tags:
WatchKit
watchOS
WidgetKit
App Intents
I have an app that has a Core Data store for dates with descriptions that I'd like to present in a widget with countdown calculations. In the app I have a button that just equates an active calculation to the currently selected item in the database (using an EnvironmentObject). I gather I can't use this mechanism inside a widget, right?
The user could put tons of items into the database - so I'm sure I don't want to have an editable widget allowing them to pick. I suppose I could create an intent and allow an independent entering from the app - but that seems rather user hostile since they've already entered it for the app - and I'm still trying to support iOS15 which doesn't support that.
I did create an App Group and have the Core Data store available from within the widget, but I don't see how to allow the user to choose which date is active. I also want multiple widgets to be able to point to different dates. Any help would be appreciated. Thanks!