我正在使用ionic和angular.js创建一个应用程序,我在注册一个服务工作者时遇到了困难,我打算用它来添加新的应用程序安装横幅功能.我按照指示在app.js文件中添加了以下代码,但是我注意到发生了注册的任何信号,也没有任何错误.
这是我添加到app.js的代码:
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js').then(function(registration) {
//Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}).catch(function(err) {
//registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
}
Run Code Online (Sandbox Code Playgroud)