Sending your first notification message

Welcome to AstroNote! AstroNote is an independent watchOS application that allows you to send push notification messages to your Apple Watch via a simple HTTP API.

In this example we will do the simplest thing possible: send yourself a message from the command line using the curl command. This may sound simplistic, but the command line and shell scripts give you unlimited possibilities.

The first thing you need is an API token, which you can grab from the Devices & Tokens page.

Sending a message is simple with the following command:

curl "https://api.astronote.app/1/notify" \
    -H "Authorization: token YOURTOKENHERE" \
    -d "title=Hello, world"

Congrats, you just sent yourself a push notification message!

In this example we only set the title of the message. You can also give the message a body by adding a body parameter.

curl "https://api.astronote.app/1/notify" \
    -H "Authorization: token YOURTOKENHERE" \
    -d "title=Hello, world" \
    -d "body=This arrives real-time on your watch"

Let’s turn the above command into a little shell script that can notify you if a big download is ready.

First, let’s create a script called downloadnotify.sh and put the following in there:

#!/bin/sh

FILENAME=$1
TOKEN=YOURTOKEN

curl "https://api.astronote.app/1/notify" \
  -H "Authorization: token $(TOKEN)" \
  -d "title=Download completed" \
  -d "body=The download of $(FILENAME) is ready."

Replace YOURTOKEN with the token you copied from the Devices & Tokens page.

Set the file mode of the script to 700 so that only you can run and read it.

$ chmod 700 downloadnotify.sh

Try it out by calling it directly:

$ ./downloadnotify.sh "Some Files"

And you should see a notification appear on your Apple Watch:

Calling this from the command line in combination with wget is now simple:

$ wget https://www.example.com/something.iso; ./downloadnotify.sh something.iso

Voila! Now when the download completes, it will send a notification to your Apple Watch.