Sub topic 2
Choosing channels: push, SMS, email and in-app
This chapter assumes you know how HTTP APIs work, what a queue is, and how to read short Python snippets. You do not need to know any provider's API yet. By the end you should be able to compare the four main channels and decide which ones a given notification should use.
Why channels matter for the design
A channel is a path that carries a message to a user. Each one has its own provider, address type, cost, delivery guarantee and set of rules. The system you design must handle these differences, so channel choice affects the whole architecture.
The four channels in this tutorial are:
- Push notifications go to a mobile app or browser through a platform service such as APNs (Apple) or FCM (Google).
- SMS messages go to a phone number through a carrier network, usually by way of an aggregator.
- Email goes to a mailbox through SMTP or an email API provider.
- In-app messages are stored by your own backend and shown inside your product, for example in a notification center.
Comparing the channels
| Property | Push | SMS | In-app | |
|---|---|---|---|---|
| Address | Device token | Phone number | Email address | User id |
| Cost per message | Very low | Highest | Low | Lowest |
| Typical latency | Seconds | Seconds | Seconds to minutes | Immediate when the app is open |
| Delivery confirmation | Accepted by platform, sometimes delivered | Carrier receipt, often unreliable | Delivered, bounced, opened (opens are unreliable) | Known exactly, as you own the store |
| Content | Short text, small payload | About 160 characters per segment | Rich HTML, attachments | Anything your UI can render |
| Reaches users who are offline | Yes, queued by the platform for a limited time | Yes | Yes | Only when they next open the app |
| Needs user permission | Yes, an OS-level opt-in | Consent required by law in many regions | Consent and unsubscribe link required | No extra permission |
Treat the table as a guide, not a guarantee. Costs and latency vary by provider and region.
Characteristics worth knowing
Push
Push is cheap and fast, and it can wake a device. Its weak points are the following:
- Users can disable notifications in their device settings, and you often cannot detect this directly.
- Device tokens expire or change, so the system must remove invalid tokens (a later chapter covers this).
- The platform may drop or delay a message if the device stays offline too long. Most platforms let you set a time-to-live (TTL), which is how long the platform keeps trying.
SMS
SMS works without an app or internet connection on the device, which makes it suitable for one-time passcodes and urgent alerts. It is also the most expensive channel, and it is regulated. Many countries require prior consent and registration of the sender. Long messages split into several segments, and each segment is billed. A message with non-GSM characters, such as many emoji, uses a different encoding with shorter segments, so cost can rise unexpectedly.
Email carries the most content and works as a durable record, such as a receipt. Its delivery is the least predictable. Spam filters, sender reputation and authentication records (SPF, DKIM, DMARC) decide whether a message reaches the inbox. Bounces and spam complaints feed back to you and must stop further sends to that address.
In-app
In-app messages use no external provider, so they are cheap, reliable and fully under your control. They only reach users who open the product. Because you store them, you can mark them read, group them and expire them. This makes in-app a good fallback or companion for every other channel.
Matching channels to notification types
Choose the channel from the purpose of the message, not from habit. Ask these questions:
- How urgent is it? A fraud alert or login code needs a fast, attention-grabbing channel. A weekly digest does not.
- Does it need a record? Receipts and legal notices belong in email, and often in-app too.
- How sensitive is the content? SMS and push previews can appear on a locked screen. Keep secrets out of them.
- What does it cost? Reserve SMS for messages whose value justifies it.
- Did the user consent? A channel the user has not enabled is not an option, whatever the urgency.
The following table gives typical starting choices.
| Notification type | Primary channel | Common companions |
|---|---|---|
| One-time passcode | SMS or push | None |
| Order shipped | Push | Email, in-app |
| Payment receipt | In-app | |
| New follower or comment | In-app, push | None |
| Weekly summary | None | |
| Security alert | Push and email | SMS, in-app |
Fallback and multi-channel strategies
There are two common patterns when more than one channel is possible.
- Fan-out: send on all enabled channels at once. This suits critical alerts, where missing the message costs more than a duplicate.
- Escalation: send on the cheapest or least intrusive channel first, then try another if the user has not acted within a set time. For example, send push, wait 10 minutes, then send SMS if the user has not opened it.
Escalation needs delivery feedback, so it depends on the tracking covered in a later chapter. It also needs care, because the user may see the same message twice if the first channel was slow but successful. Use a shared event id across channels so the app can collapse duplicates on the client.
Representing channels in code
Keep channel names as a small fixed set, and keep each channel's limits next to its name. This avoids scattering magic numbers through the workers. The sketch below picks channels for a notification type by priority and cost, using the user's enabled channels.
CHANNEL_COST = {"in_app": 0, "push": 1, "email": 2, "sms": 10}
def pick_primary(enabled, urgent):
"""Choose one channel from those the user enabled.
Urgent messages prefer attention-grabbing channels first.
Other messages prefer the cheapest channel.
"""
if not enabled:
return None
if urgent:
order = ["sms", "push", "email", "in_app"]
for channel in order:
if channel in enabled:
return channel
return min(enabled, key=lambda c: CHANNEL_COST[c])
print(pick_primary(["push", "email"], urgent=False))
print(pick_primary(["push", "sms"], urgent=True))The first call prints push, because it is cheaper than email. The second prints sms, because urgent messages prefer it.
Common mistakes
- Treating "accepted by the provider" as "delivered". A provider returning success usually means it queued the message. Track final status separately.
- Using SMS for everything. Cost and regulation make this a poor default.
- Putting sensitive data in push or SMS text. Lock screens and carrier networks expose it.
- Ignoring channel limits. Push payloads have size caps, and SMS segments change the bill. Validate content before sending.
- Sending the same message on every channel with no coordination. Users see repeats and may opt out entirely.
Exercise
A ride-sharing app must tell a rider that their driver has arrived. The rider is probably holding the phone and watching the app. Which channel would you choose as the primary one, and which would you avoid? Give one reason for each.
Show answer
Choose push as the primary channel, with in-app as a companion, because both are fast and cheap and reach a user who is already near the device. Avoid email, because it can arrive minutes late and the message is only useful for a short time. SMS is a possible fallback if the rider does not respond, but it is too costly to use as the default for a high-volume message.
Exercise
Your escalation flow sends push, waits 10 minutes, then sends SMS if the user has not acted. Some users receive both messages even though they opened the push after 9 minutes and 50 seconds. Name one cause and one fix.
Show answer
One cause is that the "opened" feedback arrives after the timer check, because delivery feedback is delayed or the check races with the event. A fix is to re-check the user's latest state immediately before sending the SMS, and to skip the send if the notification is already marked as read or acted on. Using a shared event id also lets the client hide a duplicate.