Hi everyone and Apple support,
I’ve built an app that continuously runs and receives temperature data from a sensor. When a threshold is reached, I use Live Activities with the push notification flow to display alerts on the Dynamic Island. The Live Activity and push notification flow work fine in foreground and background states. However, I’m trying to support push-triggered Live Activities when the app is in the terminated state. Since my app rarely terminates, I can’t confirm if the Live Activity push token is generated in that state. It seems like it isn’t, which blocks the Live Activity from starting via push. I tried with both pushtostarttoken and pushtostarttokenupdates. None of them worked.
Has anyone dealt with this or found a workaround to ensure the push token is available even when the app is terminated?
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
Activity
I am trying to update a widget with a push notification.
After completing all the settings, I sent a push notification via command line and got the following error:
Connection #0 to host api.sandbox.push.apple.com left intact
{"reason":"DeviceTokenNotForTopic"}
The platform is VisionOS.
Hi, I’m using SwiftData with an @Observable DatabaseManager class that is shared between my app and a widget. This class is located inside a Swift package and looks roughly like this:
public final class DatabaseManager {
public static let shared = DatabaseManager()
private init() {
let groupID = "group.com.yourcompany.myApp"
let config = ModelConfiguration(groupContainer: .identifier(groupID))
let c = try! ModelContainer(for: MyModel.self, configurations: config)
self.container = c
self.modelContext = c.mainContext
}
public private(set) var container: ModelContainer
public private(set) var modelContext: ModelContext
}
In the main app, I inject the container and context like this:
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.modelContainer(DatabaseManager.shared.container)
.modelContext(DatabaseManager.shared.modelContext)
}
}
}
Both the widget and the main app import the same package, and both use DatabaseManager.shared for reading and writing objects.
The problem:
When the widget updates an object using an AppIntent, the change is not reflected in the main app unless I fully terminate and relaunch it. If I just bring the app back to the foreground, it still shows stale data.
Is there a recommended way to make the main app observe or reload SwiftData changes that were made in the widget (via the same shared app group and container)? I’m already using .modelContainer(...) and .modelContext(...) in the app, and everything else works fine — it’s just the syncing that doesn’t happen unless I force-relaunch the app.
Thanks!
We have a Subscription based feature in our App, using which a user can say something like "Ask Mickey". However we want to enable this system Shortcut only when the user has subscribed to certain premium features.
i.e. If the User is not subscribed to Premium Services, we do not want to show this Shortcut.
However, when adding any conditional code inside AppShortcutsProvider, I am getting the following Compile Time errors:
**'AppShortcutsProvider' property 'appShortcuts' requires builder syntax
AppShortcut builders support only a platform availability if statements, not general if statements'**
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
I am trying to feature flag widgets in my Widget extension. This feature flag value is stored remotely, read by my main app, and written to UserDefaults, then read from UserDefaults in my widget target. I understand that providing an empty array of WidgetFamilys will not show my app when the user goes to add a widget.
However, even when this flag flips to true, hard-closing and reopening my app will not show my app in the list of apps you can add a widget for. But I notice that if I recompile my app from Xcode (running the app's scheme, not the widget scheme), then my app will show when you search for an app to add a widget for, making me think that these Widget objects are only created by the system once when the app is initially installed/updated.
My concern is that I will not be able to flip this flag from false to true after the user has installed my app to do a rollout of my widget. Is this expected? Or is there an alternative or otherwise recommended way of doing this?
struct MyWidget: Widget {
let kind = "MyWidget"
var supportedFamilies: [WidgetFamily] {
let manager = ExtensionManager()
if manager.widgetsEnabled {
return [.systemSmall, .systemMedium, .systemLarge]
}
else {
return []
}
}
var body: some WidgetConfiguration {
IntentConfiguration(
kind: kind,
intent: MyWidgetIntent.self,
provider: MyWidgetProvider()
) { entry in
MyWidgetView(entry: entry)
}
.configurationDisplayName("My Widget")
.description("Install my widget!")
.supportedFamilies(supportedFamilies)
}
}
Hello,
I am trying to create a Home Screen widget for iOS that displays device usage statistics — similar to the built-in Screen Time widget Apple provides. The goal is to show the average device usage for a specified period (daily, weekly, or monthly) and optionally include a comparison with the previous period.
I noticed that Apple’s own Screen Time widget presents such information. However, after reviewing the public documentation, I could not find any available API that allows a developer to create a similar experience.
To explore possible alternatives, I implemented a SwiftUI view inside a com.apple.deviceactivityui.report-extension using the Family Controls and Device Activity frameworks. The view works fine within the main app and the report extension context, but when I attempted to use the same view in a WidgetKit extension, I received an error at runtime. This suggests that views from com.apple.deviceactivityui.report-extension are not usable inside widgets, which I understand may be due to sandboxing or limitations of how the extension points are designed.
So far, I’ve found no way to access cumulative or average usage data (screen time, app usage, etc.) from system APIs that can be shown in a widget context. My understanding is that Family Controls and Device Activity frameworks allow observing ongoing activity and building usage reports inside the app, but do not provide access to the same historical or summarized data that Apple’s own widgets display.
Could you please confirm:
Whether there is any supported way to access average device usage (screen time) data for use in a widget?
If not, is this an intentional limitation due to privacy concerns, or is there a roadmap for exposing such APIs in the future?
Are there any APIs or entitlements that could allow similar functionality via WidgetKit?
Thank you for your time and support.
Best regards,
Hi All,
I’m working on a football live score app with Dynamic Island support, using iOS 18 Broadcast Notifications for Live Activities. Our workflow is:
We use the Push-to-Start token to initiate the Live Activity.
For updates, we use the Channel ID.
Start, update, and end events for Live Activities are all handled via remote notifications.
We tested on 3-4 devices simultaneously, but noticed inconsistent UI updates: some devices update properly while others do not, even when using the same Channel ID.
Checking the notification console dashboard, last week we had around 1,397 notifications published but only 555 delivered — a significant discrepancy. All devices are active and connected to reliable internet, so we’re unsure why delivery rates are so low.
Additional details:
For the start event, we set notification priority to 10.
For updates, we lowered priority to 5 per Apple’s documentation, to reduce throttling.
This adjustment improved the situation compared to sandbox testing where all notifications were priority 10.
Despite this, during weekend matches, we observed a drastic drop: out of 140 published notifications, only 2 were delivered.
This large delivery gap risks missing critical update deadlines in our app. Could anyone help us understand what might be causing this and how to improve notification delivery reliability?
Thanks in advance!
Hi all,
I'm currently implementing Live Activities using ActivityKit and facing a real-world limitation that I hope the community (or Apple) can clarify.
🔹 I can successfully start a Live Activity via APNs push (event: "start") even when the app is terminated — the Live Activity appears as expected on the Lock Screen and Dynamic Island.
However, I need to update that Live Activity using the name I assigned in the push payload (e.g., match-123). This requires calling:
Airship.channel.trackLiveActivity(activity, name: activity.attributes.matchID)
…or equivalent code in native implementations to associate the activity with its push token.
❓The problem:
If the user has never launched the app, or hasn't opened it after the Live Activity was started via push, then there’s no chance for the app to run this tracking code.
So:
✅ Live Activity starts fine via APNs
❌ I can't track the activity and register it for future push updates (by name) until the app is launched
❌ Therefore, I can't update the Live Activity without knowing the token-name mapping
🔍 My question:
Is there any way to programmatically track or associate a Live Activity (started via push) with a name for APNs updates, without requiring the app to launch?
Or put differently:
Can the system automatically track the name → token mapping if the activity is started via push?
Is there any way (via entitlement, plist config, or system event) to allow registering the activity in the background (without user launch)?
💡 Notes:
I already use pushType: .token and NSSupportsLiveActivitiesFrequentUpdates
Live Activity content is fine; only the ability to send future updates is blocked without initial app launch
Using Airship SDK for push + activity tracking, but the question is general to iOS + ActivityKit behavior
Any insight on how apps like FotMob, Uber, or sports apps handle this situation would be really helpful!
Thanks in advance.
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Tags:
APNS
User Notifications
WidgetKit
ActivityKit
I have start new live activity with push notifications,but sometimes this code"activity.pushTokenUpdates" can not callback to me,so I can't update the activity with push notifications. And I already click “Allow” button in my live activity widget.How can I solve this problem.
Here are my code:
fileprivate func observeLiveActivityForRemoteCreate() {
// obverser pushToStartToken
Task {
if #available(iOS 17.2, *) {
var beforeToken = ""
for await pushToken in Activity<HLPlatformActivityAttributes>.pushToStartTokenUpdates {
let pushTokenStr = pushToken.map{String(format: "%02.2hhx", arguments: [$0])}.joined()
// avoid send duplication
if beforeToken == pushTokenStr {
return
}
beforeToken = pushTokenStr
// send pushToStartToken to service
await HLPlatformLiveActivityBridge.registerLiveActivity(withAttributesName: self.activityAttributesName, pushToStartToken: pushToken, seq: seqCreate(), pushType: .jPush)
}
}else {
// Fallback on eralier versions
}
// obverser live activity update
Task {
for await activity in Activity<HLPlatformActivityAttributes>.activityUpdates {
if let businessLiveActivityId = activity.attributes.businessLiveActivityId, let liveActivityId = activity.attributes.liveActivityId {
Task {
var beforeToken = ""
for await pushToken in activity.pushTokenUpdates {
// here the problem:sometimes pushToken not update to me
let pushTokenStr = pushToken.map{String(format: "%02.2hhx", arguments: [$0])}.joined()
// avoid send duplication
if beforeToken == pushTokenStr {
return
}
beforeToken = pushTokenStr
// send pushToken to service
}
}
Task {
for await stateUpdate in activity.activityStateUpdates {
if stateUpdate == .active {
// live activity create
}
}
}
}
}
}
}