Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launching App Store from App in Swift

Tags:

I am creating an app, and I have a banner which promotes my other app. This is my code:

var barsButton : UIButton = UIButton(frame: CGRectMake((self.view.bounds.width / 2) - 51, self.view.bounds.height - 100, 102, 30)) barsButton.setImage(UIImage(named: "Bars Icon 2.png"), forState: .Normal) barsButton.addTarget(self, action: "openBarsLink", forControlEvents: UIControlEvents.TouchUpInside)  func openBarsLink() {     var barsLink : String = "itms-apps:https://itunes.apple.com/app/bars/id706081574?mt=8"     UIApplication.sharedApplication().openURL(NSURL.URLWithString(barsLink)) } 

However, when the user presses the button, it just takes them to the App Store, and not the specific page for my app. What am I doing wrong?

like image 703
user2397282 Avatar asked Sep 19 '14 18:09

user2397282


People also ask

How do I link to my app in the App Store?

Step 1: Go to the Apple App Store on your iOS device. Step 2: Search for your app and go to the app page. Step 3: Tap the Share Sheet button on the top right of the screen, then choose Copy Link. You can also share your app with others using available sharing methods, such as Skype.


1 Answers

You have too many protocols in your URL. Get rid of https: so the URL reads

itms-apps://itunes.apple.com/app/bars/id706081574

like image 193
Chris Droukas Avatar answered Oct 18 '22 10:10

Chris Droukas