ntfy implements message subscription and notification (no registration, no server, great)

 

Table of contents

1. Download the Delphi library of ntfy (open the open source library address of ntfy for Delphi)

2. Create a message publishing program

 3. Subscribe (receive) message program

 4. Description:

5. Program download (including library):


ntfy allows you to send push notifications to your phone or desktop from any computer using simple HTTP PUT or POST requests from scripts.

Important functions of ntfy  :

  1. No need to register an account;
  2. Free, at least for now completely free;
  3. No need to set up your own server (of course, you can also set up your own personalized server)

ntfy supports:

  • Command line (curl)
  • ntfy CLI
  • HTTP
  • JavaScript
  • Go
  • Python
  • PHP
  • Delphi

In this article, we will introduce how to use ntfy in Delphi .

Open source library address of ntfy for Delphi: GitHub - hazzelnuts/ntfy-for-delphi at net-http

Self-built server open source link (not discussed in this article): GitHub - binwiederhier/ntfy: Send push notifications to your phone or desktop using PUT/POST

1. Download the Delphi library of ntfy (open the open source library address of ntfy for Delphi)

 After downloading, add src as the directory that the Delphi project can search for!

special reminder:

        There are two branches of the library on GitHub that need attention. Since Indy was used for early development, the main branch is downloaded by default, that is, the Indy branch, which requires runtime DLL support (libeay32.dll and ssleay32.dll). If you choose the het-http branch, you will use TNetHTTP instead of Indy, so you don’t need DLL support, and you can use it on FMX and support mobile terminals.

        Of course, use the net-http branch!

2. Create a message publishing program


uses
  Notify;

procedure TForm1.Button_NotifyClick(Sender: TObject);
begin
  Ntfy.Notification(
    New.Notification
      .Topic(Edit_Topic.Text)
      .Title(Edit_Title.Text)
      .MessageContent(Edit_MessageContent.Text)
  );

  Ntfy.Publish;
end;

 3. Subscribe (receive) message program

uses
  Notify;

{$R *.fmx}

procedure TForm2.Button_SubScribleClick(Sender: TObject);
begin
  Ntfy.Subscribe(Edit_Topic.Text,
    procedure (AEvent: INotifyEvent)
    begin
      Memo1.Lines.Add(AEvent.MessageContent)
    end);
end;

 4. Description:

  1. The above two programs are running, one is to publish messages, and the other is to receive messages;
  2. No need to set up your own server, no need to register an account, just use it directly;
  3. Due to the use of TNetHTTP, it supports FMX cross-platform without DLL support;
  4. In addition to the function of sending messages, there are many other functions, you need to check the official website information by yourself;

5. Program download (including library):

serial number download link
1 Notify library
2 Demo execution program and source program

Pay attention to adding the src directory of the Notify library to the search directory of the program.

Guess you like

Origin blog.csdn.net/sensor_WU/article/details/132250380