Providing timely updates to users is key to improving their mobile experience, explains Lyft iOS engineer Max Husar, although it will increase development scope and effort. To achieve a balance between flexibility, reliability, and reusability, Lyft engineers used iOS ActivityKit to add dynamic content to their app.
ActivityKit was introduced by Apple with iOS 16.1 and iPadOS 17 to enable sharing live updates from an app using the Dynamic Island available on newer devices or the lock screen on older ones. A cornerstone of ActivityKit are Live Activities, which can be seen as an evolution of notifications in that they allow the user not only to receive up-to-date information or launch an app, but also perform functionality without launching the app through buttons and toggles.
As Husar explains, Lyft engineers handle each Live Activity as a sort of mini app that is run on top of the main app. This also reflects Lyft organization, where multiple teams work on different areas at the same time.
We decided to build live activities content to be fully server driven using server-driven user interface (SDUI). We already use SDUI frameworks for some screens in our apps that overlap with the Live Activity, so reusing basic models and familiar patterns helps us move faster.
The main limitation for Live Activities comes from the maximum allowed payload size for content updates, which is 4KB. In Lyft's case, this required both tweaking their SDUI models as well as using protobuf to further shave off some bytes from payload sizes.
Based on this approach, the iOS team at Lyft created several components to interact with the users, including a RichText component able to render formatted text along with an image or a timer, and a progress bar used to show riders how fast a Lyft car is approaching.
Additionally, they extended their solution to support the display of remote images to show the driver’s profile photo and car as soon as a rider is matched. This task required using App Groups to share files across the app and the extensions implementing the Live Activities. Even so, Lyft engineers could not find:
a way to reliably and quickly display two simultaneous images (driver picture and car). We agreed that the driver’s profile photo is more crucial to see first from UX perspective, and we can show it without any delays by sending base64 image data directly into the APNs update payload.
An additional limitation came from the fact that images can be downloaded only while an app is active, or backgrounded but it has enough background processing time left.
Overall, says Husar, the solution adopted for live activities was a success, regardless of the complexities, and made it possible to enhance the user experience of millions of users.
There is much more detail to how Lyft engineers leveraged Live Activities in their app than can be covered here, so do not miss the original article if you are interested.