I am currently working on a Swift project, and I have a button that, when pressed, should open a specific link. I've encountered an issue where using an App Store app link (let's say : https://apps.apple.com/us/app/tiny-wings/id417817520 ) results in an "invalid" response, while other links open correctly in the Safari browser of the iOS Simulator.
My code :
let appStoreLink = "https://apps.apple.com/us/app/tiny-wings/id417817520"
if let url = URL(string: appStoreLink), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
print("Invalid URL or unable to open the link.")
}
Snapshot of Simulator Output:

Is there a specific approach or alternative method I should use when dealing with App Store links in this context?
AFAIK, you can not open the
apps.appledomain from the simulator. Maybe Apple has a mechanism to block navigation to this domain, and prevent you from installing apps on the simulator. You can also try to search for the App Store via Safari directly, even if the result shows up, you can't do anything about it. The same error appears when you tap on this search result:However, I am pretty sure it will work in the production environment. It's guaranteed and also is a basic case.