Sub topic 2
Choosing channels: push, SMS, email and in-app
This chapter assumes you know how HTTP APIs and queues work and can read short Python snippets. It compares the four channels a notification system usually supports. The comparison drives routing, cost and failure handling in later chapters.
What differs between channels
A channel is a path that carries a message to a user. Each one has its own provider, cost, latency and reliability. Four properties matter most:
- Reach: whether you can contact the user at all. Push needs an installed app and a device token. SMS needs a phone number. Email needs an address. In-app needs the user to open the app.
- Cost: SMS is billed per message and varies by country. Email and push are cheap at scale. In-app is nearly free.
- Intrusiveness: SMS and push interrupt the user. Email and in-app wait until the user looks.
- Delivery feedback: email gives bounces and complaints. Push gives invalid-token errors. SMS gives carrier receipts that are often incomplete. In-app is visible in your own data.
Comparing the four channels
| Channel | Typical latency | Cost | Content | Main failure modes |
|---|---|---|---|---|
| Push | Seconds | Low | Short text, deep link | Expired token, user disabled permission |
| SMS | Seconds | High | Plain text, short | Carrier filtering, invalid number, regional rules |
| Seconds to minutes | Low | Rich HTML | Bounces, spam filtering, delay | |
| In-app | Immediate when open | Very low | Any UI you build | User never opens the app |
Push and SMS suit time-sensitive messages such as a delivery arriving or a login code. Email suits receipts and longer content the user may want to keep. In-app suits low-urgency items such as a new comment, because it never interrupts.
Matching events to channels
Do not hard-code one channel per event. Each notification type has a default set of channels, and users narrow it with their preferences. A common pattern is to try a cheap channel first and fall back to an expensive one only when it matters. For example, send push first, and send SMS only if a critical alert goes unacknowledged.
CHANNEL_DEFAULTS = {
"order_shipped": ["push", "email"],
"login_code": ["sms"],
"new_comment": ["in_app"],
}
def default_channels(notification_type):
"""Return the default channels for a type, or an in-app fallback."""
return CHANNEL_DEFAULTS.get(notification_type, ["in_app"])
print(default_channels("order_shipped"))
print(default_channels("unknown_type"))The function falls back to in_app because it is the safest channel for an unknown type. It is cheap and cannot interrupt anyone.
How channels shape the design
Because the channels fail differently, each needs its own delivery path. Push needs token cleanup. Email needs bounce handling. SMS needs cost controls. Keeping the paths separate means a slow email provider does not delay push messages.
Common mistakes
- Sending every event on every channel. Users then mute the whole app.
- Treating "accepted by the provider" as "delivered". Providers accept a message first and deliver later, or never.
- Assuming a channel is available. Always check that the user has a valid token, number or address.
Exercise
A "password reset code" must arrive within seconds, and the user may not have the app installed. Which channel fits best, and why is email a weaker choice?
Show answer
SMS fits best. It reaches the user without an installed app and usually arrives within seconds. Email can be delayed by provider queues or spam filtering, so the user may wait too long for a time-sensitive code.