Update the Image from push notification
saileshbro opened this issue · 4 comments
Hi, thanks for the awesome plugin.
I was trying to update the image with push notifications, but its not working as expected. I guess the image URL is coming because everything else is updated, only the image is not being updated. Is there any other things needed to be done?
Here are the snippets
Push Notification Payload
const notificationBody = {
aps: {
timestamp: notificationTime.seconds,
event: 'update',
'dismissal-date': endTime,
'content-state': {
heading: 'Awaiting Results',
description: prediction.text,
state: 'awaiting_results',
timerStartDate: notificationTime.seconds,
timerEndDate: predictionEndTime,
userProfilePicture: imageUrl,
},
alert: { title, body },
},
};
Here's how i am showing the images
let profileImageURL = context.state.userProfilePicture ?? sharedDefault.string(forKey: "userProfilePicture")
VStack(alignment: .center, spacing: 2.0) {
if let uiProfileImageURL = UIImage(contentsOfFile: contentsOfFile)
{
Image(uiImage: uiProfileImageURL)
.resizable()
.frame(width: 50, height: 50)
.aspectRatio(contentMode: .fit)
.clipShape(Circle())
.offset(y:0)
}
}
.padding(.bottom, 8)
.padding(.top, 8)
Hmm I’m not sure that live activities can make HTTP requests. https://developer.apple.com/forums/thread/716902
hmm, @jolamar can we do base64 image? considering the image size be 80x80? May be that should work right?
@saileshbro as long as the payload is under 4kb https://www.airship.com/resources/explainer/ios-live-activities-explained/#:~:text=Your%20app%20can%20update%20the,up%20to%204KB%20of%20data.
That works, thanks. Managed to make it under 4KB.