Jump to content


Photo

Notification by the browser with Unigui

notification

  • Please log in to reply
10 replies to this topic

#1 Fenix

Fenix

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 258 posts
  • LocationBrazil

Posted 19 October 2016 - 10:47 AM

Hi 

 

Follows a tip for using the notification by the browser.

 

Add push_notification.js in folder files

Add in the uniServerModule->CustomFiles

 

To dispare notification:

procedure FenixNotification(pTitle, pMessage:String);
var
 vJS: String;
begin
 vjs := format('jQuery(document).ready(function($){$.notify("%s",{title: "%s", icon: "http:\\dominio.com\yourimage.png"});});',[pMessage,pTitle]);
 UniSession.AddJS(vjs);
end;

procedure TFMenu.ButtonNotrClick(Sender: TObject);
begin
  FenixNotification('Fenix','Your session is expiring.';
end;

Best regards

Attached Files


  • 2
Delphi Berlin
uniGui 1.0.0.1410
Windows Server 2012 64bit IIS

#2 HarryG

HarryG

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 190 posts

Posted 19 October 2016 - 03:50 PM

Thanks for that Fenix - it works a treat.


  • 0

#3 _Mehmet_

_Mehmet_

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 493 posts
  • LocationAntalya / Turkey

Posted 19 October 2016 - 06:37 PM

thanks Fenix


  • 0

#4 HarryG

HarryG

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 190 posts

Posted 20 October 2016 - 08:37 AM

How would you go about adding an audio notification to this?

 

Cheers


  • 0

#5 Fenix

Fenix

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 258 posts
  • LocationBrazil

Posted 20 October 2016 - 03:50 PM

Hi HarryG,

 

I found nothing about audio.  :(

You can use another command before calling the notification.

 

Look at this example:

https://github.com/a...uery-play-sound

https://jsfiddle.net/admsev/xscxya0g/


  • 0
Delphi Berlin
uniGui 1.0.0.1410
Windows Server 2012 64bit IIS

#6 HarryG

HarryG

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 190 posts

Posted 21 October 2016 - 07:41 AM

Ok many thanks Fenix


  • 0

#7 roneydourados

roneydourados

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 28 June 2017 - 02:57 PM

Thanks Fenix!!!!!!!


  • 0

#8 sparkz

sparkz

    Newbie

  • uniGUI Subscriber
  • Pip
  • 7 posts
  • LocationUK

Posted 08 September 2017 - 09:26 PM

Fenix, this looks like a really useful bit of code. I'm new to the java side and am struggling to get this to work - I get "$.notify is not a function" errors. I suspect because I haven't setup things correctly.

 

Have you got a sample project with this or some other bit of JS so I can learn from it.

 

Thanks


  • 0

#9 sparkz

sparkz

    Newbie

  • uniGUI Subscriber
  • Pip
  • 7 posts
  • LocationUK

Posted 09 September 2017 - 04:19 PM

The .js file is included in the server CustomFiles: files/push_notification.js
 
I'm calling the following on a button click in the client main form:

procedure PushNotification(sTitle, sMessage: String);
var
  sJS: String;
begin
  sJS := Format('jQuery(document).ready(function($){$.notify("%s",{title: "%s", icon: ""});});', [sMessage, sTitle]);
  UniSession.AddJS(sJS);
end;

But I get the following error:

 

Attached File  Error.jpg   18.75KB   1 downloads

 

I can put the JS code into the script directly and it works fine but I can't get the interaction between calling the "notify" function and the library .js file to work. I assume it's not finding the library?

 

It seems to be one of those aspects not well documented, I'd really appreciate if someone could tell me what I may be missing... :unsure:

Attached Files


  • 0

#10 acms

acms

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 14 December 2017 - 01:53 PM

Same problem to me : "$.notify is not a function"

 

Fenix, this looks like a really useful bit of code. I'm new to the java side and am struggling to get this to work - I get "$.notify is not a function" errors. I suspect because I haven't setup things correctly.

 

Have you got a sample project with this or some other bit of JS so I can learn from it.

 

Thanks


  • 0

#11 leons

leons

    Member

  • uniGUI Subscriber
  • PipPip
  • 12 posts

Posted 14 December 2017 - 03:37 PM

Hi Fenix, 

 

Works on my local machine for Chrome, IE and Edge with the program as stand-alone server. On IIS/ISAPI on the server as dll, only Edge is working.

 

Any idea?

 

Leon


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users