Inappbrowser how to figure out the launching app is in the background?

so i have a app which has a button. on clicking the button a url is opened using the inappbroswer plugin.

my requirement is to change the button text only once the user switch back to my app that launched the url.

i want to do it for better user experience. so want to do it only once the user returns back to app from the launched browser.

Does the user have to manually go back from the InAppBrowser to your app? Any implementations automatically close the browser if the user hits a certain URL - then it is easy to also just change a button.