I’ve an React website that makes use of Apple App Web site Affiliation file to deal with Common Hyperlinks and open the hyperlinks to my website in my iOS app as a substitute, in case the consumer has the app put in.
This works completely fantastic when I’m clicking a hyperlink in some exterior location, e.g. Google search outcomes.
The issue happens when I attempt to create a popup that prompts the consumer in the event that they need to open the hyperlink in app or proceed in browser.
Reddit has related performance:
Reddit’s “Open in App” popup
Can this be carried out utilizing Common Hyperlinks or do browsers truly forestall altering Searching Context if I am already on my website?
I attempted creating this “Open in App” button:
<button
onClick={() => {
window.sessionStorage.setItem('has-reacted-to-use-in-app-popup', true);
closePopup();
// Redirect to app
window.location.href="https://www.my-app-url.com/";
// If the app isn't put in, the timeout operate will execute
setTimeout(() => {
// Redirect to App Retailer
doc.location.href="https://apps.apple.com/app/my-app-url/id1234567890";
}, 1000);
}}
>
Open in App
</button>
It really works completely domestically and opens the app if it is put in and the shop web page if not, when the URL is completely different than https://www.my-app-url.com/
In manufacturing, it solely reopens the index web page.
Thanks upfront!