istornz/flutter_live_activities

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?

That works, thanks. Managed to make it under 4KB.