We encountered an issue with universal links where the link failed to open the iOS application from Safari when triggered by an javascript outside a click event.
However, when we modified the code to open the link directly via a user click, the application launched as expected. Based on our testing, this issue seems to occur only when there is information for the application cached in Safari (i.e. IDP page cached, redirects to our app, javascript based universal link navigation fails).
Here is a code example of what caused the universal link failure:
const openUniversalLink = () => {
buttonClicked = True
}
useEffect(()=> {
if (buttonClicked) {
window.location.href = universal_link
}
}
<Button
onClick={openUniversalLink}
/>
Here is a code example of what caused our universal links to open successfully:
const openUniversalLink = () => {
window.location.href = universal_link
}
<Button
onClick={openUniversalLink}
/>
Are there defined practices of when we are able to open universal links triggered by javascript vs when they must be opened directly through user action?
Post
Replies
Boosts
Views
Activity
Hi everyone! We encountered an issue with universal links where the link failed to open the iOS application from Safari when triggered by an event listener. However, when we modified the code to open the link directly via a user click, the application launched as expected. Based on our testing, this issue seems to occur only when there is information for the application cached in Safari.
Our previous flow that resulted in the broken universal link included:
Data is loaded and a screen with a button to open the universal link is available for the user
When the data is loaded it sets a state variable to true for DataLoaded
The user clicks on the button to open the universal link
When the user clicks the button to open the link it sets a variable to true for ButtonClicked
When DataLoaded and ButtonClicked are true then the universal link is opened
Our new flow that results in the successful universal link includes:
Data is loaded and the user is hit with a loading screen until it is finished
The user clicks on the button to open the universal link and the universal link is opened directly
Does anyone have insights into why universal links must be triggered by direct user action, and in what scenarios this behavior is enforced?