Jump to content
uniGUI Discussion Forums
Sistema Fenix

Notification by the browser with Unigui

Recommended Posts

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

push_notification.zip

  • Upvote 2

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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:

 

post-5352-0-10257100-1504973953_thumb.jpg

 

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:

JSTest.zip

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

×