title: Capacitor/Ionic: Handling push notification in background or when app was killed
body: <p>Goodmorning everyone,
  I haven't been able to find a solution for several hours now.</p>
  <p>I use the &quot;PushNotifications&quot; Capacitor plugin (<a href="https://capacitor.ionicframework.com/docs/apis/push-notifications/" rel="noreferrer">https://capacitor.ionicframework.com/docs/apis/push-notifications/</a>) to listen to push notifications that come to me from firebase (both notification and data type), the listening of notifications happens very well and everything behaves as expected even in cases of app killed or in the background.</p>
  <p>The problem is the following:</p>
  <p>I want to open the app when I receive a notification, if it is in the background or if it has been killed.</p>
  <ol>
  <li><p>In the case of notification received when the app is in the <strong>foreground</strong>, I can run custom code using
  <code>addListener(eventName: &quot;pushNotificationReceived&quot;, callback)</code>
  and in any case I have no problems because the app is open.</p>
  </li>
  <li><p>In case of notification received when the app is in the <strong>background</strong>, I can force the app to keep the backgroundMode active (<a href="https://ionicframework.com/docs/native/background-mode" rel="noreferrer">https://ionicframework.com/docs/native/background-mode</a>)
  and bring the app to the foreground upon receiving a notification. (although I don't really like it because it's battery consuming)</p>
  </li>
  <li><p>In case of app <strong>killed</strong>, I have not found solutions to the problem.</p>
  </li>
  </ol>
  <p>It seems that there is no way to hook custom code to be able to run when a push notification arrives when it is received in the background or with the app killed, have you ever had this problem?</p>
  <p>Thank you!</p>