Table of Contents
onNotifications()
GCM push notifications are deprecated. wrtc_kit does not support push notifications at the moment.
wrtc.onNotifications() is an event function called when user or browser has allowed or blocked notifications.
First time wrtc.adv.startPushNotifications() is called web server will ask user to allow notifications:
After user clicked on "Allow" or "Block" wrtc.onNotifications() will be called with the results as argument.
All future wrtc.adv.startPushNotifications() calls will be answered by browser itself without asking user again. The browser remembers the user's choice. After browser allows or blocks request wrtc.onNotifications() will be called with the results as argument.
Occurs
User or browser has allowed or blocked notifications.
Arguments
wrtc.onNotifications(arg)
- arg - boolean:
- true - user or browser has allowed notifications
- false - user or browser has blocked notifications
Return value
Ignored.
Example
If user has blocked notifications in browser, javascript code cannot enable it again. Thus if wrtc.onNotifications(false) occurs we need to instruct user how to manually allow notifications again:
wrtc.onNotifications = function(success) {
if (!success)
window.alert("Notifications are blocked by browser. To enable them again please click on padlock icon in browser address field and select Notifications: Always allow on this site.");
}