Can't create a Live Activity from background

Our app is using the CLLocationManager to wake up the app near an iBeacon and then tries to connect to the accessory via bluetooth and UWB. For this to work in the background we need to create a Live Activity and show the user that the app is doing something. When the app is in the foreground or just recently got into the inactivity mode this works fine and we can use CoreBluetooth/NearbyInteraction even when the app then enters the background mode.

But when the app is longer in the background creating a Live Activity via Activity.request() throws an ActivityAuthorizationError.visibility. According to the documentation the LiveActivityIntent is able to workaround this background restriction but I get the same exception when I create the LiveActivity from the perform() method.

Is there another API to create Live Activities? Do I need to prepare the LiveActivityIntent somehow?

Thanks for the post.

Please refer to the documentation for further details. However, I would like to provide a concise summary of my interpretation: it is not possible to programmatically initiate a Live Activity from a background execution context, such as a CLLocationManager wakeup, using local APIs.

https://developer.apple.com/design/human-interface-guidelines/live-activities/

The ActivityAuthorizationError.visibility error occurs because Live Activity strictly requires the app to be in the foreground and visible to the user to start a Live Activity locally with user’s permission.

If a user taps an Interactive Widget, uses a Shortcut, or asks Siri, the System executes the LiveActivityIntent. Because the user initiated the action via the OS, Apple grants the Intent the privilege to start a Live Activity, even if your app's main process is in the background.

I would recommend you to read the workflows very carefully as Live Activity entirely as may show that you can start via Push Notification service (APNs) however the update token will come with user acceptance.

Downloading a few sample and going over those workflows will also help you to understand better how it works and the options you have.

Albert Pascual
  Worldwide Developer Relations.

Can't create a Live Activity from background
 
 
Q