Boost Your Reach: How Urban Company Mastered Push Notification Delivery

By — Rounak Saha (Engineer, Platform)

UC Blogger
Urban Company – Engineering
7 min readJun 5, 2024

--

Push Notifications (PNs) are an efficient mode of in-app communication for an organisation to engage with its user-base. It is not only cost-effective, but also facilitates convenient real-time updates to users.

This blog describes the in-house Push Notification architecture at Urban Company(UC) which enables us to successfully deliver ~90% PNs with a P75 latency of less than 60 seconds.

The Problem At Hand

At Urban Company, PNs are used to notify partners about upcoming jobs, relay order and payment updates to customers, and support promotional campaigns.

Our existing PN setup had a low delivery rate. To make things worse, our monitoring setup did not provide sufficient visibility. As a result, we began to rely on cost intensive modes of communications.

The Action Plan: Addressing the Challenges

To build higher confidence on PN as a communication mode we worked on following :

  1. 100% Transparency and Visibility: Our tracking setup needs to provide detailed information about the lifecycle of each PN. It should include the time of trigger, delivery and click on the PN.
  2. Industry Standard Delivery Rate: We conducted benchmarking studies on delivery rates in the E-Commerce domain. After conducting research across various organisations we found 80%+ to be best in industry PN delivery rates.
  3. Timeliness: Delivering PNs such as job notifications to partners in a timely manner is crucial as the Partner needs to respond within a few minutes.

Overcoming Obstacles: The New Push Notification Architecture at Urban Company

We assessed each component impacting the delivery of PNs and worked towards enhancing delivery rate at each step.

1. Push Notification Delivery Platform

PNs are typically managed by cloud messaging platforms like Google, Apple, Mi, and Baidu. These platforms internally maintain socket-like connections with devices to deliver notifications.

In our legacy system, we used Google Cloud Messaging (GCM) to deliver notifications to Android devices. However, GCM was deprecated in 2019, which led to performance issues. For iOS, we used Apple Push Notification Services (APNs).

We reevaluated all push notification platforms best suited for UC:

  1. Firebase Cloud Messaging (FCM) — FCM can facilitate push notifications on both Android and iOS platforms. However, on iOS, it merely operates as a wrapper over APNs. It also doesn’t support features such as live activities.
  2. OEM Specific Notification ChannelsBaidu Push and Mi Push provide push notifications on Baidu and Mi phones. We couldn’t identify a clear advantage with the additional management overhead.
  3. Apple Push Notification Services(APNs) — APNs is the only method for sending push notifications within the iOS ecosystem. Other providers simply serve as a wrapper over APNs.

We decided to use FCM for the Android platform as it serves all phone manufacturers. For iOS, we chose to continue with APNs.

2. Token Acquisition

Tokens act as unique identifiers that link end user’s device, PN delivery platform and our system.

In our legacy setup, we discovered that we continued to trigger PNs to tokens which were very old, resulting in failures. This happened because we retrieved token only once, ie, during app installation, resulting in stale tokens on the platform.

To address this issue, we overhauled our token acquisition process. Now, every time a user opens the Urban Company application, we synchronise the currently active token with our backend token store. For users who may not use the UC app frequently, we initiate background processes (like Work Manager) to supply fresh tokens. This strategy ensures a consistent supply of fresh tokens as long as the UC app is installed on the user’s device.

Figure 1: Token acquisition process.

3. Token Liveliness

Now that we have the latest token for a device, but at the same time there can be multiple tokens due to app reinstalls. Also, PN delivery platforms consider tokens stale if it has been inactive for over a month. Therefore, sending PNs to duplicate and stale tokens becomes futile.

Leveraging the fact that we always a have fresh token as long as the app is installed, we introduced a check to only send PNs to a token if it is not older than a month.

Figure 2: Token liveliness check.

4. Maximising Delivery for App Idle State

Now, we have all necessary components in place. Our push notification platform has been upgraded, we’ve maintained a flow of fresh tokens, and we’re ready to deliver PNs. However, we realised that our setup overlooked one crucial aspect — the idle state of the application. PNs are typically delivered effectively when the app is active on the foreground thread. Delivery rate drops when the app is either killed or moves to a background state. Moreover, user-specific settings like focus mode can restrict the delivery of critical notifications.

To overcome these hurdles, we delved deeper into the Android and iOS ecosystems.

Android Specific Optimisations

We discovered that FCM enables us to send notifications via two channels: data channel and notification channel. The notification channel is designed to deliver messages even when a device is in idle state. The following is a detailed comparison of these channels:

iOS Specific Optimisations

We started using time-sensitive notifications. This ensures users won’t miss time-critical updates, such as order updates or notifications from their IoT devices.

Figure 3: Time Sensitive Notification settings for iOS users.

5. Monitoring & Alerting

We have all the components of push notification delivery in place. The last step is to track each stage of a push notification: when it’s triggered from our system, when it’s received on the user’s device, and when the user clicks on it.

Since we’re using two different notification platforms, FCM and APNs, each has a slightly different monitoring setup.

APNs Notification Monitoring

Generally, APNs does not provide analytics at the granularity level of each PN. To get this information, our servers need a callback every time a PN is delivered to a device or clicked on by a user. However, when the app is in background state, delivery events are not exposed to the UC app.

To address this, we implemented Apple Notification Extension Services. These Notification Extensions are lightweight processes bundled with the main application, similar to a sidecar service. They enable us to intercept delivery events of PN. We simply invoke the extension to deliver data to our servers.

When a user receives or clicks a notification, we trigger API calls from the Notification Extension to our gateway service with the notification UUID. This creates a series of events for a specific notification, enabling us to effectively track all stages of a PN.

FCM Notification Monitoring

For FCM, when a notification is delivered while the device is idle, the API call to register the push notification activity is often throttled due to device-level limitations. Moreover, when a push notification is delivered using the notification channel, there’s no way to register such an API call.

In these scenarios, the FCM platform dumps data into Big Query with the notification UUID, allowing us to track all events for a specific PN. We used snow pipe to sync Big Query data to our internal data warehouse hosted on Snowflake.

Now that we have all events for a PN, we can easily track delivery rate and latency. This also enables us to setup alerts to identify any anomaly in our PN systems.

Figure 4: Setup for Monitoring Push Notification Delivery and Clicks.

Delivery & Timeliness Metrics

The above fundamental architectural changes has helped us achieve ~90+% delivery rate. We are able to deliver PNs in less than 60 seconds for 75% cases in android and 95% in iOS.

Figure 5: Metrics for Delivery Rate and Timeliness.

Future Scope

Now that we have higher confidence on PN as a communication channel, we will focus on optimising campaigns that have primarily relied on cost-intensive communication modes and transition them to a push notification-first approach.

Sounds like fun?

If you enjoyed this blog post, please clap 👏(as many times as you like) and follow us (@UC Blogger). Help us build a community by sharing on your favourite social networks (Twitter, LinkedIn, Facebook, etc).

If you are interested in finding out about opportunities, visit us at http://careers.urbancompany.com

--

--

UC Blogger
Urban Company – Engineering

The author of stories from inside Urban Company (owner of Engineering, Design & Culture blogs)