flauc / ng-push

An Angular wrapper around the Notifications API
MIT License
59 stars 12 forks source link

how to click to the notification #4

Closed OdaiTu closed 6 years ago

OdaiTu commented 7 years ago

thank you i want when click to notification to open a new window i did this code but is doesnt work

`let opiotns= { body: res.data[0].title, icon: this.imgUrl + '100x100/' + res.data[0].image, timeOut: 5000, showProgressBar: true, clickToClose: true, preventLastDuplicates: true

            }
            this._pushNotifications.create('',opiotns).subscribe(
               res.onclick = window.open(this.siteUrl + 'news/' + res.data[0].id)
            );`
anode7 commented 7 years ago

Hi @OdaiTu a functional example with this version

   this.push.create('Test', { body: 'Ici il y a du nouveau !!', icon:"android-chrome-192x192.png"}).subscribe(
        res => {
          if(res.event.type=="click"){
            res.notification.close();
            window.open(this.siteUrl + 'news/' + res.data[0].id)
          }
        },
        err => console.log(err)
      )
flauc commented 6 years ago

@anode7 thank you so much for jumping in on this one, I will add this to the documentation as well this weekend 👍

OdaiTu commented 6 years ago

solved now thanks