How to catch the fallback events on Android IOS APP or Mini Program?

problem description

I want to make a chat app where the chat list page and the chat dialog box want to be on the same page. Instead of using different pages

the environmental background of the problems and what methods you have tried

The problem with

is that because the chat dialog box and the chat list are on the same page, you cannot use the mobile entity fallback button to return to the chat list page from the chat dialog box. Because they are actually the same page.

what result do you expect? What is the error message actually seen?

I want a way to capture the back button of the phone"s physical button. Preferably javescript.

Menu