26

We prompt users to upgrade their app if they're running an outdated version. When users tap our update button, I use openURL with an address like itms://itunes.apple.com/us/app/our-app-title/id12345?mt=8 to load the App Store app to the listing for our app.

With that method, however, the resulting screen has a button labeled "Open" not "Update." If users open the App Store app first, then navigate to our app's listing (or go to the update tab), the button is labeled "Update."

Can I pass the current version as a querystring parameter in the openURL call or is there another way to make sure the Update button is shown? I cannot find current documentation on how to do so. (Everything I find is a few years old and refers to the discontinued phobos tool.)

skypanther
  • 975
  • 8
  • 19
  • 1
    I suggest you not to add this feature. You app may be rejected for showing update button. – John Wong Jan 15 '16 at 17:55
  • I'm not adding an update button in my app rather I'm directing users to the App Store app, to my app's listing, and I want the Update button to show there (rather than the default Open). We've not been rejected yet for having this in place. – skypanther Jan 20 '16 at 14:04

5 Answers5

17

I would recommend you to try SKStoreProductViewController class. iTunes item identifier can be found in https://itunesconnect.apple.com -> My Apps -> Apple ID.

swift:

func openStoreProductWithiTunesItemIdentifier(identifier: String) {
    let storeViewController = SKStoreProductViewController()
    storeViewController.delegate = self

    let parameters = [ SKStoreProductParameterITunesItemIdentifier : identifier]
    storeViewController.loadProductWithParameters(parameters) { [weak self] (loaded, error) -> Void in
        if loaded {
            // Parent class of self is UIViewContorller
            self?.presentViewController(storeViewController, animated: true, completion: nil)
        }
    }
}

func productViewControllerDidFinish(viewController: SKStoreProductViewController) {
    viewController.dismissViewControllerAnimated(true, completion: nil)
}
// Usage
openStoreProductWithiTunesItemIdentifier("2321354")

objective-c:

- (void)openStoreProductViewControllerWithITunesItemIdentifier:(NSInteger)iTunesItemIdentifier {
    SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];

    storeViewController.delegate = self;

    NSNumber *identifier = [NSNumber numberWithInteger:iTunesItemIdentifier];

    NSDictionary *parameters = @{ SKStoreProductParameterITunesItemIdentifier:identifier };
    UIViewController *viewController = [self topViewController];
    [storeViewController loadProductWithParameters:parameters
                                   completionBlock:^(BOOL result, NSError *error) {
                                       if (!result) {
                                           NSLog(@"SKStoreProductViewController: %@", error);
                                       }
                                   }];
    [viewController presentViewController:storeViewController animated:YES completion:nil];
    [storeViewController release];
}
Ramis
  • 13,985
  • 7
  • 81
  • 100
  • Thanks @Ramis, I think this is the right solution. I've been fighting bugs in production and haven't had a chance to test this out yet. I've up-voted and will circle back and accept once I finally get a chance to try this out. – skypanther Jan 20 '16 at 14:02
  • 2
    FYI, I could never get this to show up when running the simulator but it works fine on actual devices. – Eric Jul 07 '16 at 19:54
4

From News and Announcement For Apple Developers.

Drive Customers Directly to Your App on the App Store with iTunes Links With iTunes links you can provide your customers with an easy way to access your apps on the App Store directly from your website or marketing campaigns. Creating an iTunes link is simple and can be made to direct customers to either a single app, all your apps, or to a specific app with your company name specified.

To send customers to a specific application: http://itunes.com/apps/appname

To send customers to a list of apps you have on the App Store: http://itunes.com/apps/developername

To send customers to a specific app with your company name included in the URL: http://itunes.com/apps/developername/appname

Additional notes:

You can replace http:// with itms:// or itms-apps:// to avoid redirects.

For info on naming, see Apple QA1633:

https://developer.apple.com/library/ios/#qa/qa1633/_index.html.

Edit (as of January 2015):

itunes.com/apps links should be updated to appstore.com/apps. See QA1633 above, which has been updated. A new QA1629 suggests these steps and code for launching the store from an app:

  1. Launch iTunes on your computer.
  2. Search for the item you want to link to.
  3. Right-click or control-click on the item's name in iTunes, then choose "Copy iTunes Store URL" from the pop-up menu.
  4. In your application, create an NSURL object with the copied iTunes URL, then pass this object to UIApplication' s openURL: method to open your item in the App Store.

Sample code:

NSString *iTunesLink = @"itms://itunes.apple.com/us/app/apple-store/id375380948?mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];

Copied from here.

Community
  • 1
  • 1
Justlike
  • 1,476
  • 10
  • 18
  • 1
    Thanks, but I'm already linking to my app. What I need is for the App Store page to show the "Update" button when you go there, rather than the "Open" button. – skypanther Jan 20 '16 at 14:03
1

I would like to provide an answer for the Xamarin user. The following would bring up an alert offering to update and then take the user to the store.

async void PromptForVersionUpgrade()
{
        var alertController = UIAlertController.Create(Messages.NewVersionTitle, Messages.NewVersionText, UIAlertControllerStyle.Alert);

        alertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null));

        alertController.AddAction(UIAlertAction.Create(Messages.NewVersionGoToAppStore, UIAlertActionStyle.Default, (obj) =>
        {
            var storeViewController = new SKStoreProductViewController();
            storeViewController.Delegate = this;
            storeViewController.LoadProduct(new StoreProductParameters { ITunesItemIdentifier = 999999999 }, (isLoaded, error) =>
            {
                if (isLoaded)
                    PresentViewController(storeViewController, true, null);
            });
        }));

        PresentViewController(alertController, true, null);
}

Then the controller you are calling this code from would need to implement the interface 'ISKStoreProductViewControllerDelegate' to make the 'Cancel' button work. Then 'this' assignable to the 'Delegate' property.

public partial class MyCurrentController : ISKStoreProductViewControllerDelegate {

        async void PromptForVersionUpgrade() { ... }

        [Export("productViewControllerDidFinish:")]
        public void Finished(SKStoreProductViewController controller)
        {
            controller.DismissViewController(true, null);
        }

        ...
}
Anytoe
  • 1,605
  • 1
  • 20
  • 26
  • Thanks. Not being a Xamarin user I can't speak to whether this meets my original needs. My issue was not taking users to the app store page for our app. It was getting the app store to show an Update button rather than Open button when a new version was available. – skypanther Mar 29 '17 at 19:37
1

Just replace the 1166632935 with your app ID - Swift 4

UIApplication.shared.open(URL(string: "itms://itunes.apple.com/app/id1166632935")!, options: [:])

We inform our users to open the Updates tab on the App Store app and pull down to refresh if the UPDATE button isn't visible :/

budiDino
  • 13,044
  • 8
  • 95
  • 91
1

appID = https://appstoreconnect.apple.com/ -> My Apps -> 'MyAPP' -> App Information -> under GeneralInformation section present Apple ID.

Swift 5:

let params = [SKStoreProductParameterITunesItemIdentifier: appID]
let storeProductVC = SKStoreProductViewController()
storeProductVC.delegate = self
storeProductVC.loadProduct(withParameters: params)
self.present(storeProductVC, animated: true, completion: nil)
Henadzi Rabkin
  • 6,834
  • 3
  • 32
  • 39