cURL — Push notifications to your own phone

Jonas Johansen
myNotifier
Published in
3 min readMar 28, 2022

By combining cURL and the myNotifier API, you’ll be sending push notifications to yourself in no time

myNotifier

myNotifier is a simple API that lets you monitor your code with push notifications to yourself and a web dashboard. This can be helpful in a lot of ways including being notified about events in your code, errors, daily reminders, cron jobs. Basically, anything you can think of doing with code! ☝️

Getting Started

Getting started is no more than 2 simple steps and you’ll receive your first notification in 2 minutes.

  • Sign up for myNotifier (it’s fast and free) and connect your phone
  • Write a cURL command and receive notifications

Creating an account

  • Go to myNotifier and create an account.
  • Download either the Apple Store or Google Play Store app to your phone.
  • Log in on the app using the email you used for signing up and connect your device by pressing ‘Add This Device’ under the ‘Profile’ tab.
Phones connected to your account

Now your phone is ready to receive a notification.

You can add multiple phones if you want more people to receive the same notifications.

Pre-requisite

In this tutorial I’ll not be explaining what cURL is and all of its features. If you want to know more about it and learn the ins and out, I would suggest you check out the docs here ☝️

First of all, we need to make sure that you have cURL installed. You can do that by typing the below command in a terminal window.

curl --version

If not there, you can install it from here ⚡️

Sending POST requests with cURL

For you to make a POST request, you need to type in the following line in a terminal window

curl --header 'Content-Type: application/json' -d '{"apiKey":"****-****-****-****", "message": "My first cURL notification!", "description": "Awesome!"}' https://api.mynotifier.app

By using the --header we can specify which type of content we want to send. In this case, it’s JSON.

And by using -d we can specify the data we want to send along to the API.

This command would result in something like this

{"message":"something_went_wrong"}

That’s because you didn’t provide a valid apiKey.

You can get your own API key by logging in to the web app here and navigating to the ‘Account tab’ and pressing the ‘Reveal Api Key’ button.

Account Tab

Copy the key to your clipboard by clicking the ‘<Copy to clipboard>’ button.

Now the key is in your clipboard and you can replace the ‘****-****-****-****’ with the apiKey.

Some extra properties you can send along.

  • The ‘message’ and ‘description’ properties can be anything you want.
  • The ‘type’ property can be either ‘info’, ‘error’, ‘warning’, or ‘success’. It defaults to info if nothing is set.
  • The ‘body’ property can be whatever you want and can only be seen on the web app. Good for logging errors or something like that.

Now the code is ready to be run and if everything is done correctly, you should be getting push notifications to the phone(s) you set up!⚡️

This should result in something like this.

{“message”:”noti_created_successfully”,”noti”:”********some_id*******”}

The id will of course be unique to your notification.

By navigating to the ‘Dashboard’ tab in the web app, you’ll be able to see every notification that was sent.

And that’s basically everything there is to it ☝️

Closing words

If you have any kind of problems, questions, or maybe some feedback for this tutorial, please contact me on Twitter or comment on this post and I’ll respond ASAP. If you want to be a part of the growth of myNotifier and want updates on it, please give a follow ⚡️🙏

Any kind of claps, comments, or help by spreading the word would be greatly appreciated 😁

Some other tutorials you may like:

Thank you for reading and as always, remember to keep on coding on 💙

All the best,

Jonas A.

--

--

Jonas Johansen
myNotifier

Passionate about software development and indie business. Currently building mynotifier.app & granolio.co ⚡️🥣