Page 1 of 1

Notification

Posted: Fri Sep 14, 2018 2:42 pm
by Peter
just a snippet...

Code: Select all

Procedure ShowNotificationCallback()
  Debug "ShowNotificationCallback()"
EndProcedure

Procedure ShowNotification(Title.s, Message.s, Icon.s = "", Callback = #PB_Ignore)
  
  ! if (!Notification) {    
  Debug "This browser doesn't support desktop notification"
  !   return;
  ! }
  
  ! if (Notification.permission !== "granted") {
  !   Notification.requestPermission();
  ! } else {
  !   var notification = new Notification(v_title, { icon: v_icon, body: v_message, });
  If Callback <> #PB_Ignore
    ! notification.onclick = function () { v_callback() };
  EndIf
  ! }
  
EndProcedure

ShowNotification("Notification title", 
                 "This is a simple desktop notification", 
                 "http://icons.iconarchive.com/icons/paomedia/small-n-flat/64/cat-icon.png",
                 @ShowNotificationCallback())

Re: Notification

Posted: Fri Sep 14, 2018 6:50 pm
by Paul
Using Chrome v68 here ... the page is blank (other than the default blue SpiderBasic background) and the debug window is empty.

Re: Notification

Posted: Fri Sep 14, 2018 9:41 pm
by Peter
Paul wrote:Using Chrome v68 here ... the page is blank (other than the default blue SpiderBasic background) and the debug window is empty.
please open the console (<F12>) and reload the page. Is there an error message?

Greetings ... Peter

Re: Notification

Posted: Fri Sep 14, 2018 10:08 pm
by Paul
This is the error listed ...


Image

Re: Notification

Posted: Fri Sep 14, 2018 10:24 pm
by Peter
Paul wrote:Image
ok, this is a 'normal' error message, because SpiderBasic does not create/copy the favicon file. Strange...

that's what it would look like if it worked for you:
Image

(testet with Linux Chrome and Firefox and Windows 2012 Chrome and Firefox (IE doesn't work (of course))

Re: Notification

Posted: Sat Sep 15, 2018 12:57 am
by Paul
This was annoying me so I went into my Chrome settings and found this (which I know is the port SpiderBasic uses) ...

Image

I deleted it and then ran your code again and this time it worked.
I must have been doing something in the past which caused this entry to exist in Chrome.

Cool code snippet by the way :)