title: Android Local Notification with Angular Service Worker
body: <p>I'm building a PWA using the latest version of Angular. </p>
  
  <p>I'm making use of the <a href="https://github.com/angular/mobile-toolkit" rel="nofollow noreferrer">Angular Mobile Toolkit</a> and I want to send Local Notifications using <a href="https://github.com/angular/mobile-toolkit/tree/master/service-worker/worker" rel="nofollow noreferrer">angular/service-worker</a>. But I can't make it work.</p>
  
  <p>I'm able to subscribe and send notification from a server, but I would like to send a notification from my app itself. I tried using <a href="https://github.com/flauc/angular2-notifications" rel="nofollow noreferrer">angular2-notifications</a>, it works well on a desktop, but the constructor</p>
  
  <pre><code>new Notification(title, options) 
  </code></pre>
  
  <p>from the Notification API doesn't work anymore on Android, so it doesn't suit me.</p>
  
  <p>Is there any way to use <a href="https://github.com/angular/mobile-toolkit/tree/master/service-worker/worker" rel="nofollow noreferrer">angular/service-worker</a> to send local notifications on Android (Chrome)? Or maybe another alternative.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Maciej answer pointed me to the right direction, I was able to make it work using the following piece of code</p>
  
  <pre><code>navigator.serviceWorker.getRegistration() 
           .then((reg) =&gt; { 
                  reg.showNotification(title, noti); 
             });
  </code></pre>
  
  <p>P.S.: Be aware that I used this together with <a href="https://github.com/angular/mobile-toolkit/tree/master/service-worker/worker" rel="nofollow noreferrer">angular/service-worker</a>. I used <a href="https://github.com/angular/mobile-toolkit/tree/master/service-worker/worker" rel="nofollow noreferrer">angular/service-worker</a> to register the service-worker and the code above uses the registered service-worker. Also, be aware that for the service-worker to work you need a secure connection.</p>