Push Notifications from Scratch

Episode #394 by Teacher's Avatar David Kimura

Summary

Progressive Web Apps are about to get a huge bump in functionality on iOS devices. Starting in iOS 16.4, we will be able to receive push notifications natively on our iOS devices from our Ruby on Rails PWA. In this episode, we explore creating push notifications from scratch without the need of a Google or Apple developer account.
rails notifications ios progressive web app pwa vapid 38:45

Chapters

  • Introduction (0:00)
  • Tweaks from Episode 212 (2:33)
  • Creating alert dialog to allow notifications (3:10)
  • Handling notification permissions (5:01)
  • Setting up VAPID keys (9:07)
  • Registering the service worker (11:26)
  • Sending the subscription to the Rails application (12:39)
  • Quick recap (14:19)
  • Creating the Push Subscription (15:58)
  • Accept the subscription on the server side (17:16)
  • Persisting the subscription (18:17)
  • Securing the persisted information (19:52)
  • Storing the registered devices (22:11)
  • Filtering logs to exclude the subscription (23:24)
  • Creating background jobs (24:33)
  • Sending the Notifications (28:53)
  • Receiving a pushed notification (33:23)
  • Adding default_url_options (36:43)
  • Forgot to add to_json (37:34)
  • Demo of Push Notifications (37:56)
  • Final thoughts (38:07)
Student & Teacher
$ 9 /mo

Valid School Email Required

Same Access as Pro

Subscribe Now
Pro Monthly
$ 19 /mo

Access to Pro Episodes

Invite to Slack Channel

Priority Suggestions

Ad Free

Subscribe Now
Pro Annual
$ 190 /yr

Access to Pro Episodes

Invite to Slack Channel

Priority Suggestions

Ad Free

Subscribe Now
Teams
$ 57 /mo

3 Users Minimum

$19.00 / user / month

Same Access as Pro

Subscribe to Teams