Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Onesignal handleRecievedNotification content gets called only once

$
0
0

@saurabhgupta1995 wrote:

Hello, i have an application that uses oneSignal push notifications.
in which i am handling the data.payload on recieving a notification and it works fine.

What i want is whenever i recieve a notification i want certain tasks to happen.

when i recieve the 1st notification, it enters the openOneSigalMessage and handleNotificationRecieved() and does everything inside the fuction but
When there is 2nd notification, it does receive the notification but does not enter the code.

Can anyone suggest me how can i call handleNotification everytime i get a Notification

For that i have written this code

openOneSignalMessage() {
this.oneSignal.handleNotificationReceived().subscribe((data) => {

  alert("Notification received:\n" + JSON.stringify(data));
  console.log('Did I receive a notification: ' + JSON.stringify(data));
  this.events.publish('Event1', data);
  console.log('Event 1 published from app components ')
  console.log('data payload', data.payload);
  console.log('data payload additional body', data.payload.additionalData.refresh);

  let refreshMsg = data.payload.additionalData.refresh


  if (refreshMsg == "TUGLIST") {
    this.events.publish('TuglistOfApp', refreshMsg);
    console.log('Entered if of tuglist of app.component');

  } else if (refreshMsg == "TASKLIST") {
    this.events.publish('TasklistOfApp', refreshMsg);
    console.log('Entered if of Tasklist of app.component');

  }
});

console.log("Open Event Notification");
this.oneSignal.handleNotificationOpened().subscribe((data) => {
 
});

}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>