Automating iOS push notifications with Railway and OneSignal
Design overview of a notification server I created in Python that runs on Railway and automates mobile push notifications to my app's users when a new ticket is approved.
Background
I built a mobile app that allows users to contribute information. Each new contribution creates a new ticket that is reviewed manually.
To encourage more contributions from the community, each time a ticket is approved, a push notification is sent to that user’s device using a notification server I created.
Overview of notification server design
Notification database table
Each time a ticket is approved, a new job is added to a PostgresSQL table that the notification worker is listening to. I hosted the table on Supabase with he rest of my project but, this architecture will work with other providers and flavors of SQL. The key thing for the database piece is that it
Notification worker
The notification worker is a python script that I deployed to Railway and then configured it to run every 5 minutes. Railway makes it easy to spin up services like this that scale and you’re only billed when the server is active. The script checks if there have been any new notifications that need to be sent out by checking for the notifications with a “pending” status.
Once a pending row is picked up, the worker orchestrates 1) sending the right data to OneSignal to deliver the push notification and 2) updates the status of the notification in the PostgreSQL table to prevent duplicate notifications being sent to the end user.
Notification delivery
I decided to use OneSignal which is the 3rd party push notifications provider to make managing the delivery to users easier to manage. Managing the end delivery requires token management, retires, and other logic I didn’t think it was worth building out of the box for only a only a couple hundred users a month that would be contributing.
To deliver the notifications, OneSignal receives the External ID (user_id) from the notification worker, looks up the user’s subscribed device that is correlated with it and then handles delivers the push through Apple’s APNs (on iOS).
OneSignal tried to send the notification and it only succeeds if the user has notification permissions enabled.


