Jump to content

Notification by the browser with Unigui


Sistema Fenix

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

  • Like 1
  • Upvote 3
Link to comment
Share on other sites

  • 8 months later...
  • 2 months later...

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

Link to comment
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

Link to comment
Share on other sites

  • 3 months later...

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

Link to comment
Share on other sites

  • 5 years later...
On 10/19/2016 at 8:47 AM, Sistema Fenix said:

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.zipUnavailable

Alguém ainda tem esse arquivo (push_notification.zippara disponibilizar? Gostaria de implementar no meu projeto.

Link to comment
Share on other sites

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...