Post not yet marked as solved
We are interested to know what is the rate limit on the push notifications for live activities. We understand there is a "budget" on the amount of push notifications on a users device. But is there some rate limitation we should be aware of on APNs?
Post not yet marked as solved
i'm struct dynamic island detail content
dynamicIsland: { context in
DynamicIsland {
expandedContent(context: context)
} compactLeading: {
....
} compactTrailing: {
...
}
i want show different content based on context.
private func expandedContent(context: ActivityViewContext<xxxx>)->DynamicIslandExpandedContent<some View> {
if (context.state.style == 0) {
return expandedControlContent1(context: context)
} else if (context.state.style == 1) {
return expandedControlContent2(context: context)
} else {
return expandedControlContent3(context: context)
}
}
compiles error
Function declares an opaque return type 'some View', but the return statements in its body do not have matching underlying types
Post not yet marked as solved
Is something wrong with testing live activities on Dynamic Island in iOS 17?
It works fine for devices without dynamic island.
It's a timer countdown. Initially, it didn't show up on the iPhone 15 Pro, but after installing and reinstalling the app it showed up. But now, the timer freezes like it was freezing while it was being tested on a simulator.
Is there something extra I should be doing for the Dynamic Island Display?
P/S: The app uses only Live Activities without the widget.
Post not yet marked as solved
My background audio app stops updating its Live Activity after the iPhone locks, and doesn't resume updating the activity after tapping the screen or even after FaceID unlocks the device (without opening the lock screen).
My live activity requests a ContentState update & iOS updates the content for the activity as below:
Task{
log.debug("LiveActivityManager.updateLiveActivity() with new ContentState")
await liveActivity.update( ActivityContent(state:contentState, staleDate:nil) )
}
Below what my log looks like:
<<<<SWIPE LOCK SCREEN DOWN>>>>
DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState
iOS: Updating content for activity 0A519263-1E46-4BB6-BA4F-F3DDBC081AB4
DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState
iOS: Updating content for activity 0A519263-1E46-4BB6-BA4F-F3DDBC081AB4
<<<<PRESS LOCK BUTTON->Lock iPhone>>>>
INFO: --------protectedDataWillBecomeUnavailableNotification--------
DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState
iOS: Updating content for activity 0A519263-1E46-4BB6-BA4F-F3DDBC081AB4
DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState
DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState
DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState
<<<<LOOK AT & TAP LOCK SCREEN->Unlock iPhone without swiping up>>>>
INFO: --------protectedDataDidBecomeAvailableNotification-----------
DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState
DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState
DEBUG: LiveActivityManager.updateLiveActivity() with new ContentState
As shown in the log, normally iOS updates the content for my activity after my liveActivity.update request.
This works fine in the Dynamic Island and when after switching apps and swiping down to see the lock screen without locking the phone.
However, once I lock the phone, iOS stops updating the Live Activity content, and doesn't resume updates until after the app regains the foreground at least once.
Has anyone else encountered this behavior? Is this a setting that I'm missing, or a bug?
Post not yet marked as solved
Hi all,
I'm trying to implement starting Live Activities with push notifications according to this article:
https://developer.apple.com/documentation/activitykit/starting-and-updating-live-activities-with-activitykit-push-notifications
I'm using Xcode 15.1 beta 3, I have run my tests on a physical device with iOS 17.2 as well as the simulator with iOS 17.2
My problem is I can't seem to be able to get the pushToStartToken needed to start the live activities. I have subscribed to the pushToStartTokenUpdates but I never get any updates.
Here is the code I used:
Task {
do {
for try await data in Activity<DailyGoalActivityAttributes>.pushToStartTokenUpdates {
let token = data.map {String(format: "%02x", $0)}.joined()
print("Activity token: \(token)")
}
} catch {
print(error)
}
}
Any help would be greatly appreciated.
Thanks,
HS
Post not yet marked as solved
Hello all,
I am trying to start Live Activity from remote push notification with the new ActivityKit api.
The documentation for starting live activity from a push notification says:
When the system receives the ActivityKit push notification on a device, it starts a new Live Activity, wakes up your app, and grants it background run time to allow you to download assets that the Live Activity needs.
While the system starts the new Live Activity and wakes up your app, you receive the push token you use for updates. To update and end the Live Activity, use this update push token as if you obtained it by starting a Live Activity from within your app.
Is there any information on how to get access to the background runtime and the push token, when the app is in background when the Live Activity is started? I can get the pushToStartTokenUpdates if the app is already running and push notification arrives (and starts the Live Activity), but not in the background, which makes getting updates not possible unless user launches the app.
Thanks!
Post not yet marked as solved
In iOS 17.2 we can start a live activity by push, and the document says:
When the system receives the ActivityKit push notification on a device, it starts a new Live Activity, wakes up your app, and grants it background run time to allow you to download assets that the Live Activity needs.
My problem is, in which callback can I be notified a live activity will be start by a push, so I can download some web contents such as images before the live activity be rendered.
Post not yet marked as solved
When setting a systemActounForegroundColor, no effect is seen on the lock screen when swiping away a Live Activity. Attempted with custom color assets and system colors, but maybe I am using it incorrectly?
@available(iOS 16.2, *)
struct DevicePollingLiveActivityWidget: Widget {
typealias constants = DevicePollingLiveActivityConstants
var body: some WidgetConfiguration {
ActivityConfiguration(for: AlarmPollingActivityAttributes.self) { context in
DevicePollingLockScreenView(deviceEvent: context.state.device)
.activityBackgroundTint(.clear)
.activitySystemActionForegroundColor(.white)
} dynamicIsland: { context in
DynamicIsland {
// Expanded UI goes here. Compose the expanded UI through
// various regions, like leading/trailing/center/bottom
DynamicIslandExpandedRegion(.leading) {```
Post not yet marked as solved
In a live activity view, the update occurs upon pressing the button intent but does not automatically refresh after the application transitions to the background in SwiftUI.
I want to update my live activity every X minutes but it is not working while app in background mode and app going background mode to suspend mode after some time automatically
How can i update my live activity every X minutes using background Task.
Post not yet marked as solved
I have app that shows live activity and countdown till a date...
VStack {
Text("Countdown till You finish your homework")
Text(countdownTime, style: .timer)
}
After the time up, the live activity countup, the solution is to update the live activity via backgroundTask and this not always working, really apple sometimes fire the backgroundTask after hours.
Another solution is to set dismissalPolicy: .after(countdownTime), but once I did that the dynamic island not working and the activity status is ended after right calling...
await activity.end(using: state, dismissalPolicy: .after(countdownTime))
Can anyone help please, users feed back is why you we still see the old task on live activity. How come I can not update live activity? and how come if you set dismissalPolicy .after apple changes the activity status to ended and stop showing the dynamic island?
Post not yet marked as solved
There's an issue in the iOS 17 beta where passing nil to activityBackgroundTint(_:) does not use the system's default background material as expected. Instead, it's showing a solid black color instead of the correct tint that matches the rest of the system in iOS 16.
Post not yet marked as solved
Hello,
i am implementing Live Activity and facing a problem setting custom color for widget background.
I have a dedicated catalogue of colors for WidgetExtension each having light/dark variant.
The problem is, however, that widget's view changes color variants (any/dark) according to system settings, but not system background & text of widget set via .activityBackgroundTint(_:) and activitySystemActionForegroundColor(_:)
Both widget background and system button texts remain in light variant no matter what system setting was when starting Live Activity.
Later, i was able to kinda force LA background color by checking color scheme in my widget view (yellow and brown for test purposes)
.activityBackgroundTint(colorScheme == .light ? Color.surface. : Color.brown)
this would force Live Activity background to have expected color from start.
BUT
when i later change appearance in system settings Live Activity behaves weirdly, as if it was caching previous color I provided.
I installed 16.2 beta in hope that it was fixed, but noticed this behaviour 👇
system in light mode: LA start, LA background is light
set system to dark: LA background light
set system to light: LA background dark ❗️
set system to dark: do not pull notification center, do not look at LA, instead immediately 👇
set system to light: LA background light
Is there any way around this? 🙏
Post not yet marked as solved
How can i pause and resume
Text((context.state.startTime.convertStringToDate() ?? Date()), style: .relative) and
ProgressView(
timerInterval: progressStartDate...Date().addingTimeInterval(TimeInterval((Int(earnTime) ?? 0) * 60)),
countsDown: false,
label: { EmptyView() },
currentValueLabel: { EmptyView() }
)
I couldn't find any document to pause and resume activity
Post not yet marked as solved
When is there going to be access to the ScreenTime API / ActivityKit API so that we can programmatically access Phone Pickups and Screen Time for applications?
Currently, the information is limited to getting callbacks when a threshold is hit or approached, but we don't know really anything about what the threshold is, and we cannot do that in the background.
It seems incredibly limited on scope.
Any thoughts or estimates on when this might be possible? Thank you so much!
Post not yet marked as solved
I'm using Text(targetDate, style:.relative) to show how a countdown of minutes until a given event. Unfortunately, this includes seconds, which takes unnecessary space and can get quite distracting when used on the dynamic island.
There are many examples of apps that show estimates like "7 minutes" or "7 min" but how do they get the countdown to update? Are background updates reliable enough for this? Surely they don't send a push notification every minute to update the remaining time? Or is there some formatting option that I'm missing?
Post not yet marked as solved
Environment:
iOS Version: 17.2
iOS Simulator Version: 17.2
Xcode Version: 15.2
Device: iPhone 15 Pro Max
App Target Version: iOS 17.2
Preconditions:
App with Live Activity feature is installed.
Device/Simulator is running iOS 17.2.
Steps to Reproduce:
Start the app and initiate a Live Activity with text styled as .timer.
Lock the device screen or switch to the lock screen view in the iOS Simulator.
Observe the Live Activity on the lock screen, noting the text style.
Unlock the device. This time noting the .timer changed its style.
The text style of the Live Activity remains consistent both on the lock screen and after unlocking the device, maintaining its .timer style throughout its lifecycle.
Frequency:
Occurs every time the steps are reproduced.
Post not yet marked as solved
LiveActivity is effective in ios16, but error reported only in ios14
Some error message reported from Xcode:
Process: LiveExtension [20099]
Path: my.app/PlugIns/LiveExtension.appex/LiveExtension
libswiftCore.dylib
swift_getAssociatedTypeWitness
SwiftUI
BodyAccessor.makeBody(container:inputs:fields:)
SwiftUl
closure #1 in WidgetGraph.init(rootBundle:)
Post not yet marked as solved
All the documentation I've found so far is made for SwiftUI (I understand it was primarily designed for use with SwiftUI), but I'm still not able to find if there is even a way to do it. I tried to implement this very simple tutorial (https://www.youtube.com/watch?v=oloHJn1kj3w) and since it is done with SwiftUI, I tried to make a hybrid using UIHostingController, but had no luck. I made sure the configuration was set correctly, and I think it is because when I enter the app's settings (from the iPhone's settings app) the live activities button is there and turned on.
Knowing how to do it would be awesome, but I would be satisfied with at least knowing if it is even possible, before wasting more time. Thanks.
Post not yet marked as solved
Can I have a play/pause button in a Live Activities notification for the user to play an audio file if he/she chooses to? Kind of like a Spotify-style/Apple-Music-style play/pause/skip/rewind functionality but in the long-lasting Live Activities notification. Thank you.