Alessandro Nestola
Alessandro Nestola

Reputation: 31

Ionic execute code after entry page from other app

I have a problem with a payment system that works with external links opened via a browser.

I need, on returning to the app, to check that the operation has been successful.

I tried to put everything in ionViewWillEnter () but it is not called when I return the app from a second app.

Upvotes: 0

Views: 190

Answers (1)

Sergey Rudenko
Sergey Rudenko

Reputation: 9235

Ideally you want your server-side to trigger something like that (once external payment gateway processed payment, normally you want them to callback your server end point so that you could push message to notify your client).

If you need an event that can be listened to when user returns back to your app, you might want to consider Page Visibility API

Basic usage is that you need to listen to "visibilityChange" event:

document.addEventListener(visibilityChange, handleVisibilityChange, false);

Then your method should trigger necessary actions inside handler:

handleVisibilityChange() {
  if (!document.hidden && paymentWasInProgress) {
    checkPaymentStatus();
  }
}

Upvotes: 0

Related Questions