I have added support for HTML5 Notifications through the NotificationProvider class and the WebNotification interface.
Examples of usage: In the html page, define this function to ask user permission to receive notifications:
var notificationShow = function (notif) {
if (!Notification) {
return;
}
if (Notification.permission !== "granted") {
Notification.requestPermission();
} else {
var notification = new Notification(notif.title, {
icon: notif.icon,
body: notif.body,
});
notification.onclick = function () {
window.open(notif.link);
};
}
}//notifyUser
var myNotif={
title: "New message",
link: "http://localhost/deep_link",
body: "You have got new messages(5)",
icon: "http://someicon"
};
notificationShow(myNotif);
NOTE. I'm not handling deep linking at this time, so the notification will only put the app in foreground / open the app, but will not link right to the specified page.
I have added support for HTML5 Notifications through the
NotificationProvider
class and theWebNotification
interface.Examples of usage: In the html page, define this function to ask user permission to receive notifications:
The code is based on https://github.com/jnordberg/irccloudapp/blob/master/NotificationProvider.m.
NOTE. I'm not handling deep linking at this time, so the notification will only put the app in foreground / open the app, but will not link right to the specified page.