'Web Notification' user control allows the user to send messages that can be displayed even when the browser is minimized. It is useful when you want to notify users about relevant messages.
Each notification has a title, message and can have an icon to be displayed.
User must grant permission in order to work properly.
Note
HTML5 Web Notifications is supported in Google Chrome and Safari only.
Properties
Icon |
The image to be display inside the message container. |
Duration |
The seconds that the message will be displayed. 0: means forever). Default: 8 seconds. |
PermissionPromptMessage |
Web Notifications requires the user to grant permission. This message will be displayed within client screen in order to invite the user to grant permission. |
Methods
ShowMessage |
Character: Title, Character: message body |
Events
OnShow |
Fired when message is shown to user. |
OnClose |
Fired when message is closed by user. |
OnClick |
Fired when message is clicked by user. |
Code Snippet
Event Start
WebNotification1.Icon = "http://cdn1.iconfinder.com/data/icons/onebit/PNG/onebit_38.png"
Endevent
Event Enter
WebNotification1.ShowMessage("Message Title","Message Body")
Endevent
Event WebNotification1.OnClose
msg("Notification was closed!")
EndEvent
Event WebNotification1.OnShow
msg("Notification was shown!")
EndEvent
Event WebNotification1.OnClick
msg("Notification was clicked!")
EndEvent
Note that the most common use of this user control is within the OnMessage event, see Server.Socket external object for more information.
The following example shows how the notification message is captured in a web panel and displayed using the Web Notification user control.
Event OnMessage(&NotificationInfo) //&NotificationInfo is NotificationInfo data type.
if (&NotificationInfo.id = "Reservation confirmed")
webNotification1.ShowMessage("Reservation Confirmation",&NotificationInfo.Message) //webNotification1 is the user control name.
endif
Endevent
Limitation
Under the hood it uses Web Notifications (part of the HTML5 standard). It's only implemented in Google Chrome for now. So Google Chrome or Safari is required in order to work properly.
Download the user control from here.