Videos
I got really annoyed when I tapped the share button on the Amazon app for a product and the long product description was copied along with it. Android gave you the ability to do this natively so I wanted to bring it to iOS as well.
I thought it would be way easier than this but the share output actually contained the product URL twice so I had to remove the duplicate.
If there’s any other app that also copies extra text when you tap on the share button this shortcut will work with them as well.
Here’s my implementation: https://www.icloud.com/shortcuts/df7d4ffe0e7540af9ea711e1cb82c0ea
The above answers did help me, however it gave me mixed results.
For some reason using the amazonToAlipay:// did not let me reach the desired product.
Using universal links, while they should work in theory, gave me mixed results. On some devices where the amazon app was installed, the amazon app opened without problems however on others, it opened in Safari even though the Amazon app was installed.
This could be because of device type, iOS versions or something else, go figure.
So as a work around, the following gave me the best results.
Using https://www.appsight.io/app/amazon as Milan suggested, I used the following scheme which was mentioned there:
com.amazon.mobile.shopping
Step 1. Whitelist this URL Scheme in your info.Plist by adding the following
<key>LSApplicationQueriesSchemes</key>
<array>
<string>com.amazon.mobile.shopping</string>
</array>
Step 2. In my case, I needed to open a specific product on Amazon and get the product id which is present in the URL and build your string in the following format:
com.amazon.mobile.shopping://www.amazon.com/products/{your-product-id}/
Step 3. Try to open the amazon app url but also handle the case where the app might not be installed
func openAmazonProduct(withId id: String) {
guard let amazonWebURL = URL(string: "https://amzn.to/2MQC8Bz"),
let amazonAppURL = URL(string: "com.amazon.mobile.shopping://www.amazon.com/products/\(id)/") else {
return
}
if UIApplication.shared.canOpenURL(amazonAppURL) {
UIApplication.shared.open(amazonAppURL, options: [:], completionHandler: nil)
}
else if UIApplication.shared.canOpenURL(amazonWebURL) {
UIApplication.shared.open(amazonWebURL, options: [:], completionHandler: nil)
}
}
So after some more research, based on https://www.appsight.io it seems that the amazon app does not use "amzn://" url scheme, but "amazonToAlipay://". After changing it to this, the UIApplication.shared opens the Amazon app.
Thanks to @LinusGeffarth and his answer to another related question.