title: Ionic 2 - run code inside app when receiving push notification
body: <p>I'm implementing push notifications in a Ionic 2 app for Android. For this, I'm using the following function:</p>
  
  <pre><code>registerPush() {
      this.push.register().then((t: PushToken) =&gt; {
          return this.push.saveToken(t, {ignore_user: false});
      }).then((t: PushToken) =&gt; {
          this.push.rx.notification().subscribe(msg =&gt; {
              // execute some code
          });
      });
  }
  </code></pre>
  
  <p>With this, I'm able to receive push notifications sent from server. While the app is in foreground, the <code>execute some code</code> part is run without problems. While the app is in the background (I'm using the background plugin), the push notification is received, but when I click on it nothing happens.</p>
  
  <p>I want to execute the notification code in this situation too, and open the app when I click it. Is there any way to achieve this?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I've read the plugin documentation and changed the code accordingly:</p>
  
  <pre><code>registerPush() {
      this.pushNotifications = Push.init({ android: { senderID: "xxxxxxxx" } });
  
      this.pushNotifications.on('registration', data =&gt; {
          // send token to server
      });
  
      this.pushNotifications.on('notification', data =&gt; {
          // handle notification
      });
  
   }
  </code></pre>
  
  <p>With this, and with <code>content-available</code> set to 1 in the notification sent from server, the app executes the code whether I'm inside it or not.
  However, I'm still not able to put it in foreground when I click the notification.</p>