mirror of
https://github.com/tenrok/vue-native-notification.git
synced 2026-06-11 01:12:26 +03:00
2 lines
2.0 KiB
JavaScript
2 lines
2.0 KiB
JavaScript
(function(){function a(i,u,c){function f(r,n){if(!u[r]){if(!i[r]){var o="function"==typeof require&&require;if(!n&&o)return o(r,!0);if(s)return s(r,!0);var t=new Error("Cannot find module '"+r+"'");throw t.code="MODULE_NOT_FOUND",t}var e=u[r]={exports:{}};i[r][0].call(e.exports,function(n){var o=i[r][1][n];return f(o||n)},e,e.exports,a,i,u,c)}return u[r].exports}for(var s="function"==typeof require&&require,n=0;n<c.length;n++)f(c[n]);return f}return a})()({1:[function(n,o,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});var l=window.Notification||window.webkitNotification;var t=function n(o){};var e=function n(o){o.preventDefault();window.focus();o.target.close()};var i=function n(o){};var u=function n(o){};var p={onerror:t,onclick:e,onclose:i,onshow:u};var c={install:function n(o,w){w=w||{};w.requestOnNotify=w.requestOnNotify||true;o.notification={};o.prototype.$notification={};var v=function n(){return l.requestPermission()};o.notification.requestPermission=v;o.prototype.$notification.requestPermission=v;var r=function n(u,c,o){var r=o.onerror,f=r===undefined?function(){}:r,t=o.onclick,s=t===undefined?function(){}:t,e=o.onclose,a=e===undefined?function(){}:e,i=o.onshow,d=i===undefined?function(){}:i;return Promise.resolve().then(function(){if(w.requestOnNotify&&l.permission!=="granted"){return v()}return l.permission}).then(function(n){if(n==="denied"){return new Error("No permission to show notification")}try{var o=new l(u,c);var r=function n(o){"use strict";p.onerror(o);f()};var t=function n(o){"use strict";p.onclick(o);s()};var e=function n(o){"use strict";p.onclose(o);a()};var i=function n(o){"use strict";p.onshow(o);d()};o.onerror=r;o.onclick=t;o.onclose=e;o.onshow=i;return o}catch(n){if(n.name!=="TypeError")throw n;return navigator.serviceWorker.ready.then(function(n){return n.showNotification(u,c)})}})};o.notification.show=r;o.prototype.$notification.show=r}};if(typeof window!=="undefined"&&window.Vue){window.Vue.use(c)}r.default=c},{}]},{},[1]);
|