Jump to content

Notification help!


Recommended Posts

No, I took an example from the forum!
Toast is working.
But what they're asking me is to display the notification on windows, because users leave the application in the browser open all day, and they need to see the notifications!
I need to know if there is a way? And if there would be any material for me to study, because I'm starting!
Thanks!

Link to comment
Share on other sites

20 hours ago, sicoobcooplivre said:

Would you help me?

Hello,

Simple usage example.

1. UniServerModule.CustomFiles ->

files/push.min.js

2. MainForm OnCreate ->

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with JSInterface do
    JSAssign('getGranted', [JSFunction('','ajaxRequest('+ Self.WebForm.JSName +', "getGranted", ["granted="+Push.Permission.get()])')]);
end;

3. MainForm ->

private
    { Private declarations }
    FPermission: string;
  public
    { Public declarations }
  end;

4. MainForm OnAjaxEvent ->

procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = 'getGranted' then
  begin
    FPermission := Params.Values['granted'];
  end;
end;

5. UniTimer OnTimer ->

procedure TMainForm.UniTimer1Timer(Sender: TObject);
var
  ATitle, ABody, AIcon: string;
  ATimeoutMS: Integer;
begin
  if FPermission<>'denied' then
  begin
    ATitle := 'Hello';
    ABody := 'UniGUI';
    AIcon := '';
    ATimeoutMS := 5000;

    JSInterface.JSCode(
      'Push.create("'+ATitle+'",'+
      '{'+
        'body: "'+ ABody +'",'+
        'icon: "'+ AIcon +'",'+
        'timeout: "'+ IntToStr(ATimeoutMS) +'",'+
        'onClick: function () {'+
        '    window.focus();   '+
        '    this.close();     '+
        '}'+
      '});'
    );
  end;
end;

 

  • Like 3
Link to comment
Share on other sites

  • 4 weeks later...
  • 11 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...