istornz / flutter_live_activities

A Flutter plugin to use iOS 16.1+ Live Activities ⛹️ & iPhone Dynamic Island 🏝️ features
https://dimitridessus.fr/
MIT License
179 stars 54 forks source link

Support other assets and not just images #29

Open JulianBissekkou opened 1 year ago

JulianBissekkou commented 1 year ago

I am developing a live activity that needs to get a .json file which will be used to render a lottie animation. This is not an image and therefore I can't use LiveActivityImage.

My proposal would be to create LiveActivityFileAsset. This can be resolved to the actual asset in kotlin and swift using

// registrar is of type "FlutterPluginRegistrar"
let key = registrar?.lookupKey(forAsset: "Images/topImage.png")
let topPath = Bundle.main.path(forResource: key, ofType: nil)!

Same should work for android.

You can then grab the asset using

let myAssetPath = sharedDefault.string(forKey: "someAsset")
istornz commented 1 year ago

Hello, thanks for the suggestion but I don't think it's possible... In the official Apple documentation, it's written:

The updated dynamic data for both ActivityKit updates and ActivityKit push notifications can’t exceed 4KB in size.

Do you have tried in a full native project to test if it's feasible ? Thanks

JulianBissekkou commented 1 year ago

I didn't do any testing. Just to clarify: I don't want to send the whole data over to my live activity. I want to access a filepath that is stored in my main app. The 4KB transfer limit shouldn't be a deal here if i am able to configure that.