admin管理员组

文章数量:1026989

I’m working on an iOS app that uses Live Activities to display dynamic content. The app is set up to handle server-initiated live activities using push notifications. I want to download an image URL from the notification payload, cache it, and then share the cached image path with the live activity extension.

What I’ve Done:

  • Set up App Groups to share data between the app’s main target and the live activity extension.
  • Successfully implemented client-initiated live activities where I fetch and cache the image locally, and the live activity reads the cached image path.
  • Can fetch and display cached images in the app.

The Problem:

I’m struggling with server-initiated live activities. Specifically:

  1. How can I intercept the live activity push notification sent by the server to download and cache the image before the live activity starts?
  2. How do I pass the cached image path to the live activity extension after caching it?

What I’ve Tried:

  • Implemented application(_:didReceiveRemoteNotification:fetchCompletionHandler:) to log and cache images from push notifications, but I’m not sure how to connect this step to the live activity.
  • Read about UNUserNotificationCenterDelegate methods but can’t figure out the best place to intercept the notification for live activities.

Expected Outcome:

I want to:

  1. Intercept the server-initiated live activity push notification.
  2. Download and cache the image locally.
  3. Pass the cached image path to the live activity extension via the shared App Group.

How can I achieve this? Any advice, patterns, or sample code would be greatly appreciated!

I’m working on an iOS app that uses Live Activities to display dynamic content. The app is set up to handle server-initiated live activities using push notifications. I want to download an image URL from the notification payload, cache it, and then share the cached image path with the live activity extension.

What I’ve Done:

  • Set up App Groups to share data between the app’s main target and the live activity extension.
  • Successfully implemented client-initiated live activities where I fetch and cache the image locally, and the live activity reads the cached image path.
  • Can fetch and display cached images in the app.

The Problem:

I’m struggling with server-initiated live activities. Specifically:

  1. How can I intercept the live activity push notification sent by the server to download and cache the image before the live activity starts?
  2. How do I pass the cached image path to the live activity extension after caching it?

What I’ve Tried:

  • Implemented application(_:didReceiveRemoteNotification:fetchCompletionHandler:) to log and cache images from push notifications, but I’m not sure how to connect this step to the live activity.
  • Read about UNUserNotificationCenterDelegate methods but can’t figure out the best place to intercept the notification for live activities.

Expected Outcome:

I want to:

  1. Intercept the server-initiated live activity push notification.
  2. Download and cache the image locally.
  3. Pass the cached image path to the live activity extension via the shared App Group.

How can I achieve this? Any advice, patterns, or sample code would be greatly appreciated!

本文标签: