Examples and FAQ
IE9 and older
The pushclient will throw javascript exceptions on IE9 and older. Replace your javascript initialization block with this:
<!--[if IE]>
<script>window._tikPush=function(){var o=arguments;m="browserNotSupported",f="function","ready"===o[0]&&typeof o[2]===f&&o[2](m),"pushAvailable"===o[0]&&typeof o[1]===f&&o[1](!1,m)};</script>
<![endif]-->
<script>
!function(t,e,i,s,c){t[c]||(t[c]=function(){(t[c].q=t[c].q||[]).push(arguments)},
t[c].l=1*new Date,n=e.createElement(i),firstScript=e.getElementsByTagName(i)[0],n.async=1,
n.src=s,firstScript.parentNode.insertBefore(n,firstScript))}(window,document,"script",
"//www.tickaroo.com/pushclient-web/pushclient.js","_tikPush");
</script>
This will prevent our library from getting loaded at all and replace _tikPush with a minimal implementation.
Sending Notifications to web clients
If you use our default service worker, you can easily adjust the notification request to customize the push notification.
Example:
{
"uid": "testmessage-1",
"channels": ["testchannel"],
"headline": "Headline",
"message": "Hello World",
"web": {
"notification": {
"options": {
"data": {
"url": "https://example.com/some/example/page"
},
"icon": "/images/example.png"
}
}
}
}
This body will result in the following data sent to web clients:
{
"notification": {
"title": "Headline",
"options": {
"body": "Hello World",
"data": {
"url": "https://example.com/some/example/page"
},
"icon": "/images/example.png"
}
}
}
The service worker calls showNotification to display the notification. “notification.title” will be the first parameter and “notification.options” the second.
“headline” and “message” will be merged to the corresponding keys. If “notification.options.data.url” is present, the service worker listens for clicks on the notification and opens the given url on click.
View Overview to see the basics.