UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Link To App Store From UIAlertController

Forums > iOS

How do I link to the App Store from a UIAlertController?

I have a standard NSString text "message" in which I'd like to add a link to an app in the App Store. Any ideas as to how this can be done?

 override func viewWillAppear(_ animated: Bool) {

    let currentVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
    let defaults = UserDefaults.standard
    let storedVersion = defaults.string(forKey: Default.versionKey)
    print ("Stored Version: \(storedVersion ?? "None")")
    print ("Current Version: \(currentVersion ?? "None")")
    if (currentVersion != storedVersion) {
        defaults.setValue(currentVersion, forKey: Default.versionKey) // comment out for testing
        let message = cpu8proVersion.message1_0 + setWarningMessage ()
        showPopupWithTitle(title: "Thank you for using The Product", message: message, interval: 0.5)

func setWarningMessage () -> String {
    if (DeviceFamily.IS_IPHONE) {
        return cpu8proVersion.curtesyWarning
    return ""

func showPopupWithTitle(title: String, message: String, interval: TimeInterval) {
    let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
    present(alertController, animated: true) {
        let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.dismissAlertController))

@objc func dismissAlertController(){
    self.dismiss(animated: true, completion: nil)


All apps on the the store have a https link eg https://apps.apple.com/gb/app/bus-quizzes/id1465159349. if you goto the app store and tap the share button you can find the link.

it looks like that you just want the user to update the app, however this is automatically by Apple as user may have update over wifi only set. Your best bet is just to tell user that updates are available abd if the user wants to update they install it manually.


Actually, this is inform users that a new app in a family of apps is available.

How do I provide a URL in the UIAlertController? Can UIAlertController segue to a WKWebKit Controller and automatically use the URL link?


You can actually show the store page and update within the app. When user hasn't updated in 10 days my app shows the store page, and when the users closes it it just pops back up, haha. Update you shall!

import StoreKitTest 
func showStorePage() {
    let params = [SKStoreProductParameterITunesItemIdentifier: "123456789"]
    let storeProductVC = SKStoreProductViewController()
    storeProductVC.loadProduct(withParameters: params)
    storeProductVC.delegate = self
    present(storeProductVC, animated: true)

//delegate method that gets called when the store page closes
func productViewControllerDidFinish(_ viewController: SKStoreProductViewController) {
    viewController.dismiss(animated: true) {

I can show the code that checks if there is a new version too if you like.


Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.