How to detect the smart app banner via JS?

Currently I'm showing a custom app smart banner. I want to hide the custom smart app banner when the user has already installed the app. Since I'm using universal links a banner to open the current page in the app is shown automatically. How can I detect the native smart app banner provided by Safari via JS?

4 years later this is still impossibile.

How to detect the smart app banner via JS?
 
 
Q