How to link to Update page for our app

大憨熊 提交于 2019-12-22 01:33:55

问题


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.)


回答1:


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];
}



回答2:


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.




回答3:


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 :/




回答4:


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);
        }

        ...
}


来源:https://stackoverflow.com/questions/32460124/how-to-link-to-update-page-for-our-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!