'Mobile Browser: How to open a redirect link in the original tab?

What I'm trying to do, in mobile-safari / iOS is:

  1. in my web-app, open a deep-link into an app installed on the user's phone
  2. the user signs a message in this app
  3. the app redirects back to my redirect_url, coming back to my web-app
  4. my web-app parses the query-params added to the redirect_url by the app

This is a basic flow of how my web-app can communicate with a native mobile-app on a user's mobile-browser. I'm wondering though; is there a way to set the redirect_url such that the redirect comes BACK to the original tab that was open? It will be a page-refresh, meaning any in-memory data will be lost, but I can survive that. It's just weird that iOS will open up multiple tabs of my web-app every time we do a loop, and also I can't even guarantee that iOS will open up the same web-browser (it might go from Chrome to Safari if Safari is default, for example).

Ideally, I'd like to use the same web-browser, same tab every time. I'm using window.location.replace(connectURL) to do the redirect by the way.

Any solutions / suggestions for this communication flow? Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source