IOS – How to stop Safari from hijacking Amazon app links

applicationsiosiphonesafari

Apple iPhone SE with iOS 13.5.1:

When I open an Amazon hyperlink from an email or imessage it will launch the Amazon app and before it can fully open, Safari will hijack the link and open Amazon in Safari.

I don't want Safari to do this. I want to view Amazon links in the Amazon app. Safari does not do this with other app links like Yelp and Quora. Quora links launch and open Quora app with no Safari hijacking.

I have tried clearing all cache and web data in Safari. I have deleted and reinstalled the Amazon app. It still does the same thing.

Google searches have become fruitless as it seems most people prefer to view Amazon in the browser vs. the app, which puts me in the minority and makes it difficult to find information on my problem (Opinion: Is it just me, or has the Google's search function degraded over the past few years?).

I haven't been able to isolate whether this is an iPhone/iOS problem or it is an Amazon app problem.

Edit: (Requested information)

I have the latest Amazon app installed v15.12.6

Here is the example link that gets "hijacked":

https://www.amazon.com/dp/1635616271/

Additional info:

Rebooted my phone and it made no difference.

For some reason I thought being on wifi vs LTE 4G would make a difference. It didn't.

I tested a few links from the "amazon.com/apple-app-site-association".

These links launched the app and were not kicked to Safari:

https://www.amazon.com/deals

https://www.amazon.com/gp/aw/h.html

This is a link found in the "apple-app-site-association" and it was kicked to Safari:

https://www.amazon.com/products

These links were kicked to Safari:

http://amzn.com/1635616271

https://www.amazon.com/dp/1635616271

https://www.amazon.com/dp/1635616271/ref=cm_sw_su_dp

In the "apple-app-site-association" I found this:

"/dp/??????????"

So according to the "apple-app-site-association" this link should not be kicked to Safari, but it does:

https://www.amazon.com/dp/1635616271

This link:

http://amzn.com/1635616271

opens in Safari and is then kicked to the Amazon app and then the Amazon kicks it back to Safari and Safari opens it up to:

https://www.amazon.com/dp/1635616271/ref=cm_sw_su_dp

Does all of this testing indicate a bug in the Amazon app with its URL handling? Declared associations are not being properly handled. Can anyone else confirm the behavior?

Best Answer

It's not Safari hijacking the link but rather the Amazon app reading the link it was passed and declaring that it can't handle the link, throwing it back at Safari to handle generically.

  1. Amazon's website declares the links that should open in the app should the app be installed on your iPhone. You can download this list yourself by going to amazon.com/apple-app-site-association.
  2. Opening a link on iOS which matches one of these links will instead pass the link to the Amazon app.
  3. The app ‘opens’ the link (switching Amazon to the foreground) and the Amazon app ‘reads’ the contents of the link, attempting to navigate to a reasonable page within the Amazon app to reflect the intention of the link. This uses application(_:continue:restorationHandler:).
  4. If for whatever reason the Amazon app was unable to complete the intention of the link, the Amazon app can return false ‘to let iOS know that [the] app did not handle the activity’. This occurs within the Amazon app code.
  5. Since the Amazon app refused to open the link, Safari is opened as a backup and navigates to the link.