Push notifications are a powerful way to keep yourself or others updated in real-time. With ntfy.sh, you get a simple and efficient solution for sending notifications without complex setup. In this article, we’ll go through what ntfy.sh is and how you can use it to send notifications from various platforms.

What is ntfy.sh?
ntfy.sh is an open-source service that allows you to send push notifications via a simple REST API. It works across multiple platforms and can be used for both personal and professional purposes. You can send notifications directly to your phone, browser, or other clients, and it requires no advanced setup.

Getting started:

Very simple with cURL:

 curl -d "Hello from ntfy.sh!" https://ntfy.sh/supersecrettopic

I personally use ntfy.sh to send notifications when I generate leads through my affiliate websites 🤑. I’ve packaged it into a Composer package – tykfyr/ntfy-php. Here’s how you install the package:

composer require tykfyr/ntfy-php

You’re pretty much set up to start sending notifications directly to your phone with PHP. Pretty smart, right?

The next step — the fun part — is to start sending notifications. But how do we do that? Here’s a simple code snippet that uses my Composer package:

use Tykfyr\Ntfy\Client;

$ntfy = new Client('supersecrettopic');

$ntfy->send('Backup job finished!');
$ntfy->send('Deployment failed!', [
    'priority' => 5,
    'title' => '🚨 Error in deployment',
    'tags' => ['warning', 'deploy'],
    'click' => 'https://example.com/status'
]);

You can read more on ntfy.sh, and their documentation (for the tech-savvy) can be found at docs.ntfy.sh.

Leave a Comment

Your email address will not be published. Required fields are marked *