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:
- How can I intercept the live activity push notification sent by the server to download and cache the image before the live activity starts?
- 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:
- Intercept the server-initiated live activity push notification.
- Download and cache the image locally.
- 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:
- How can I intercept the live activity push notification sent by the server to download and cache the image before the live activity starts?
- 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:
- Intercept the server-initiated live activity push notification.
- Download and cache the image locally.
- 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!
本文标签:
版权声明:本文标题:swiftui - How to Intercept Live Activity Push Notification to Download, Cache, and Use Image in iOS? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1736008113a1378042.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论