How do I begin development for Live Activities?

Follow Apple’s docs:

  • Add a new† (widget) target to your app. Make sure you select ‘Live Activities’.
  • Add the necessary plist items.
  • Add push notification capability. Only needed if you want to start / update from server. If everything is done from within the app then you don’t need this. Example ‘Clock’ App on iPhone adds timers to your phone without any server interaction.
  • Not sure why but by adding the widget, Xcode automatically adds a TimelineProvider. It’s useless for Live Activities. You can delete it.

Note: A widget is a specific kind of app extension.

Does killing the app stop an active Live Activity?

No. For me it remained in Dynamic Island and Lock screen

Does killing the app cause live activities not to be delivered?

My live activity was able to get started. I haven’t tested yet if my app gets callbacks or not…

What’s the feature difference between a Live Activity and a Regular Push Notification?

Notifications have a fixed layout, with no ability to animate nor buttons to interact with.

Live Activities have custom UI and are far richer. Can be animated up to two seconds (or more see here). Can also have buttons added onto them. Live Activity is also positioned at where the dynamic island is at. It persists on the screen and morphs into different presentations

What’s the difference between Live Activity and Dynamic Island?

  • Dynamic Island is a physical location of certain newer models. First introduced in iPhone 14 Pro, and then on every model since then.
  • Live Activity is an Apple feature. Think of it as a shape shifting notification.
  • The Live Activity appears in the dynamic island when the phone is unlocked. If a phone doesn’t have a live activity then it appears as a notification

What forms does the Live Activity take?

Apple calls the ‘presentations’. The Live Activity can appear in multiple presentations:

  • Dynamic Island
    • Compact
    • Expanded
    • Minimal (attached or detached)
  • Lock Screen

For an in-app UI, see Does the Live Activity appear when app is in foreground? Apple requires you to have all presentations added. You can’t skip any of them.

How do I create an Expanded view?

The expanded view is made up of four sections.

“Expanded View
Expanded View

You can share the leading / Trailing views between the expanded and compact. See here

Note:

  • A Live Activity that’s started from a push Notification is immediately expanded upon its arrival. Then within a few seconds it shrinks down to a compact presentation.
  • While a live activity that’s started from the app isn’t shown immediately at all. It’s starts showing in compact presentation after app is backgrounded.

Does the Live Activity appear when app is in foreground?

Yes/No. It does not show anything. But if there’s an alert then you’d hear its sound.

For in-app experience:

  • You need your own UI. Figure out where / when you should or not show it.
  • You can rely on the ActivityUpdates for changes in content and use that to update the in-app UI.

How do live activities and regular notifications stack against each other on lock screen?

Live activities sit on top of regular notifications.

How long can a Live Activity remain on the screen?

  • Maximum of 8 hours on dynamic island
  • Maximum of 12 hours on lock screen.
  • or sooner if user dismisses it.

Can I use a start token to update an existing Live Activity?

No. You need to use an update token to update an existing live activity. When I tried that the Console logged:

Unsupported push notification event type for pushToStart subscription: update

I was actually surprised that the push notification made to the OS. I would have that that APNS would have gated it, but perhaps their tokens are opaque enough that APNS just blindly passes them to the OS. Not sure…

How can I remove a Live Activity from the screen?

Dismissing a live activity should not cancel the activity.

There are different ways to dismiss:

  • From the compact presentation, you can swipe left on its center. You can swipe AGAIN to bring it back ‼️
  • From the expanded presentation, you can’t swipe left nor dismiss it.
  • From the lock screen presentation, you can dismiss it like regular notifications. You can NOT swipe again to bring it back.

⚠️ - Swiping from the compact presentation, only hides the Live Activity. The Live Activity will still remain on the lock while swiping on the lock screen will dismiss the Live Activity. Neither swipes should end your activity. That should be done through some explicit action.

So how can I cancel and remove an activity?

In the Apple Clock app, dismissing a Live Activity timer does NOT stop the timer. It just removes it from your dynamic island. Similarly, if you dismiss the live activity of an Uber trip, then it does NOT cancel the trip. Apple just removes the live activity from your dynamic island / screen.

If you needed to cancel an activity, then you can either add cancel buttons onto the live activity, and then allow users to cancel the timer using certain actions associated with the notification or allow users to tap on the live activity, open the app and then end it from within the app.

Cancelling should only be done upon an explicit action which should then dismiss the Live Activity for you as well.

“canceling
Apple Clock App canceling with an App Intent Action

Will the user get prompted to give access for tokens?

YES/NO. The start token is issued provisionally. The update token though requires explicit user permission at the lock screen. At least that’s how it’s been for me.

When the Live Activity is started from the app, the user is NOT prompted at that time.

But then as soon as you unlock, assuming the Live Activity is still on the screen, the user will get the choice of “Don’t Allow” , “Allow”.

Additionally if you don’t hit “Allow”, then you will NOT get update tokens.

👉 Next Post - Live Activities - Development