istornz / flutter_live_activities

A Flutter plugin to use iOS 16.1+ Live Activities ⛹ī¸ & iPhone Dynamic Island 🏝ī¸ features
https://dimitridessus.fr/
MIT License
161 stars 48 forks source link

Live Activity ID in UserDefaults not the same as in Flutter #78

Open m-schmale opened 6 months ago

m-schmale commented 6 months ago

Hi 👋

Not sure if this is a misunderstanding on my side or a bug. I compared the Live Activity IDs I get when I create a Live Activity with the ID that is written in the UserDefaults and they don't match.

How I get the Live Activity ID in Flutter: final String? activityId = await _liveActivitiesPlugin?.createActivity(data);

  1. First app start
    • New activity is created with ID: 6D135D3F-C206-44F9-A98E-7C572A962509
  2. Second app start
    • New activity is created with ID: B8A4C9A9-A430-40CE-AFE2-63B070A6C40A
    • Current behavior: The ID used as a prefix in UserDefaults is 94B54E24-C3E5-479B-BF2B-F1728C9F4748
    • What I expect: The ID used as a prefix in UserDefaults should be 6D135D3F-C206-44F9-A98E-7C572A962509
  3. Third app start
    • New activity is created with ID: DC95BAAB-7E6D-4CEA-B49E-B307AF9EA433
    • Current behavior: The ID used as a prefix in UserDefaults is 992D58AA-B824-40A7-AF3C-9CB04DEA1E70
    • What I expect: The ID used as a prefix in UserDefaults should be B8A4C9A9-A430-40CE-AFE2-63B070A6C40A

Could you please explain this?

Thanks 🙏

m-schmale commented 6 months ago

I have noticed that in createActivity() the UUID of LiveActivitiesAppAttributes is used as prefix:

https://github.com/istornz/flutter_live_activities/blob/9ef3bfb56f8fc1ed537ec08646e391fe6e79058d/ios/Classes/SwiftLiveActivitiesPlugin.swift#L199

But the activity identifier of the created iOS live activity is returned:

https://github.com/istornz/flutter_live_activities/blob/9ef3bfb56f8fc1ed537ec08646e391fe6e79058d/ios/Classes/SwiftLiveActivitiesPlugin.swift#L233

Tomorrow, I will try to update a specific live activity by push notification. Unfortunately it doesn't work for me as described in the documentation:

To set matchName for a specific notification, you just need to grab the notification id you want (ex. 35253464632) and concatenate with your key by adding a _, example: 35253464632_matchName.