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

How to use push when the app is closed?

$
0
0

@victorcarvalhosp wrote:

I'm using the push plugin, and work's perfectly when the app is open, but when the app is closed the method is not called...

My code look like this:

this.platform.ready().then(() => {
  console.log('Platform ready');
  this.initPush();
}

initPush() {
  let push = Push.init({
      android: {
          senderID: "XXXXXX"
      },
      ios: {
          alert: "true",
          badge: true,
          sound: 'false'
      },
      windows: {}
  });

  push.on('registration', (data) => {
      console.log("REGISTRATION");
          localStorage.setItem('token', data.registrationId);
  });

  push.on('notification', (data) => {
      console.log('ONLY WORK'S WHEN APP IS OPEN')
  });

  push.on('error', (e) => {
      console.log(e.message);
  });

}

How can I do to show the message from my push at any moment?

Thank's!

Posts: 4

Participants: 3

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>