In Swift 4.2 and Xcode 10.2
You have two ways to open App Store or iTunes Store
If you want to open App Store use https or if you want to open iTunes Store use itms
Ex: https://itunes.apple.com/in/app/yourAppName/id14****4?mt=8 //For App Store
itms://itunes.apple.com/in/app/yourAppName/id14****4?mt=8 //For iTunes Store
Method 1: This is simple direct and old approach
let url = NSURL(string: "https://itunes.apple.com/in/app/smsdaddy/id1450172544?mt=8")//itms https
if UIApplication.shared.canOpenURL(url! as URL) {
UIApplication.shared.openURL(url! as URL)
}
Method 2: New approach
if let url = URL(string: "https://itunes.apple.com/in/app/smsdaddy/id1450172544?ls=1&mt=8") {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
// Earlier versions
if UIApplication.shared.canOpenURL(url as URL) {
UIApplication.shared.openURL(url as URL)
}
}
}