I need to start my non-changing live activity at specific time e.g. after 5 mins or 1 hour. There are two way I can start at later date:
- Using Local notification, but I will need the user to interact with
it for it to actually call a method which starts the activity. May be user doesn’t seen that local notification and I will not get chance to start activity by calling a method. - Using push notifications, we can start live activity. But my live activity doesn’t update once I start it. Here is why:
I am using System UI component ProgressView
that support auto-updating a live activity. So once I start live activity, the progress bas updated automatically every second, and that’s why I don’t need a push notifications to update my activity.
struct ParkWidgetAttributes: ActivityAttributes {
var startDate: Date
var endDate: Date
// 'ContentState' represents the dynamic content of the Live Activity.
public struct ContentState: Codable, Hashable {
// Dynamic stateful properties about your activity go here!
var parkingTimer: ClosedRange<Date>
}
}
Here is how activity is updated:
ProgressView(timerInterval: context.state.parkingTimer,
countsDown: false)
.padding(.horizontal, 3)
.padding(.bottom, 5)
.tint(.fastParkTint)
The reason why I do not want to use push notifications is my activity doesn’t updates once it is started. Is there some other way, or I will have to use push notifications?