1 of 22

SimplePush

What it is, how to use it

2 of 22

The Problem

  • Keeping a socket open is expensive.
  • Costly for servers and devices.
  • It’s easy for a device to find a server.
  • Hard for a server to find a device.

3 of 22

Solution:

  • Reduce the number of sockets required.
  • Give apps an endpoint they can use to wake the app on the device
  • Ensure user has privacy and control.

4 of 22

How it works: From the user’s POV

An installed app displays a page with a subscribe button.

5 of 22

How it works: From the user’s POV

User sees confirmation page (optional) and goes about their day.

6 of 22

How it works: From the user’s POV

Later, the user gets an action relevant to their selected interest and great joy is had.

7 of 22

How it works: From the user’s POV

When the user no longer �wants updates, it is easy

to disable them.

8 of 22

How it works: Behind the curtain

An App defines in it’s Manifest, that it wants to use Push notifications.

{� "permissions": {� "push": {"description": "To receive Cat Fact notifications"}� },� "messages": [� {"push": "/view_to_launch.html"},� {"push-register": "/view_to_launch.html"}� ]�}

9 of 22

How it works: Behind the curtain

Once the user selects the app, it displays the web page defined in the “push-register” of the manifest.

10 of 22

How it works: Behind the curtain

On that page, the javascript calls�navigator.push.register()

and gets back an object containing the endpoint:

e.g.

https://push.services.mozilla.com/update/01aLongStringOfCrap123...

11 of 22

How it works: Behind the curtain

The app sends the endpoint to it’s own server.

When something interesting happens and the application is not already connected to the server, it PUTs a version number to the endpoint.

curl -X PUT “https://push.services.mozilla.com/update/01aLSOC...” �--data “version=1”

12 of 22

How it works: Behind the curtain

The client gets the notification from push.services.mozilla.com, activates the app and sends a ‘push’ event message with the new version.

13 of 22

How it works: Behind the curtain

The app can then connect back to the app server and process commands normally.

14 of 22

Best Practices

Simplepush is a doorbell not a walkie talkie.

X

15 of 22

Best Practices

SimplePush is data free. Don’t rely on version numbers, just know that they will increase.

16 of 22

As to Q:

Why not send data through SimplePush?

We don’t want to be subpoenaed.

17 of 22

As to Q:

Can we send a notification to everyone that uses our app?

Sure. Just send one per registered endpoint.

18 of 22

As to Q:

No, I mean can I send a single push that updates every client of mine?

No. You can’t. There are a few reasons for that (including user privacy, again). We’re working on a “bulk update” where you can update a bunch of endpoints in one go, but it’s not ready yet.

19 of 22

As to Q:

What’s the cost?

Hopefully free, but we may ask heavy users to donate.

20 of 22

As to Q:

What’s the benefit of using this?

  • You don’t have to maintain a bunch of machines holding idle socket connections.
  • Your user’s phones battery will last longer.
  • Hopefully, it’s pretty simple to set up and use.

21 of 22

Any other Questions?

22 of 22

More information: