When you send an SMS message but your phone doesn’t have great signal it will continue to try to send the message in the background, even if you close the app. Pretty useful right?

In this post we’re going to see how to replicate this behaviour in a web application using the Background Sync API from the Service Worker.

What we need

To demonstrate the Background Sync API let’s build a feature into an existing application, a web based SMS inbox for a Twilio number. You may have already seen this app when we implemented web push notifications for incoming text messages.

To run the application, you will need:

Once you have those bits sorted, you can either download the application from GitHub or clone it using git.