coconauts / NotificationListener-cordova

NotificationListenerService plugin for Cordova/Phonegap
Other
36 stars 28 forks source link

How can I manipulate the data obtained? #13

Closed jecorralesrtm closed 4 years ago

jecorralesrtm commented 4 years ago

I am here because I am trying to manipulate the information obtained from the plugin, but I have reached an obstacle where I cannot handle or push the JSONdata I need, such as the title and the text, to an array.

I am using IONIC 5 and I can say that it works correctly by displaying notifications as follows

constructor(public navCtrl: NavController) {

    this.setNotificationListenerCallback();

  }

  setNotificationListenerCallback(){
    notificationListener.listen(function(n){
      alert("Received notification " + JSON.stringify(n) );
    }, function(e){
      setTimeout(this.setNotificationListenerCallback, 1000);
      alert("Notification Error " + e);
    });
  }

But if I try to push the data obtained to an arrangement, it does not generate any action. Simply, it is blank, which does not allow us to move forward because I need to list the notifications in my Ionic application and thus generate the history of it.

Can someone help me or if what I need is possible?

Thanks!