This library is a client-side implementation for ntfy server, made in Delphi. You can send and receive instant notifications via http. The maintainer of ntfy is Philipp C. Heckel. As he stated, this service will remain free, and every kind of support to help affording with cloud hosting will be warmly received. You too can self-host a ntfy server. Visit docs.ntfy.sh to get started and also don't forget to leave a star on his project.
You need to add src
folder to your library path or search path.
You can push notifications in topics. Topics are like channels and the name you choose will become a public url, so make sure to not choose an easy one to guess.
uses
Notify;
begin
Ntfy.Notification(
New.Notification
.Topic('your-very-secret-topic')
.Title('⚾ Go to the game')
.MessageContent('Tomorrow at 10:00hs ')
);
Ntfy.Publish;
end;
You can subscribe by many ways. For instance, the Web App, Android, CLI or you can use this library this way:
uses
Notify;
begin
Ntfy.Subscribe('your-very-secret-topic',
procedure (AEvent: INotifyEvent)
begin
WriteLn('You received a message: ' + AEvent.MessageContent)
end);
end;
IOS still rely on FCM and "inteligently" decides to kill background/foreground processes when it wants. It was not properly tested yet. All other platforms have been tested and can either publish or maintain a subscription background activity suspended for long hours without having any issues. Refer to these samples to learn to use in your project. No tests have been performed on Linux at the present moment.
Ntfy for Delphi makes use of a few libraries to subscribe and publish. There is no need to install them. Respective credit is awarded to the creators:
- NxHorizon by Dalija Prasnikar.
- JsonToDelphiClass by Petar Georgiev.
- NetHTTP native components.
- Indy10 by IndySockets.
Check the wiki page for specific instructions, updates or tutorials. I've created this implementation for passion and curiosity and it will remain an open source project under the MIT license. Feel free to use, contribute and improve this project!